DefaultValues of TMSQuery info

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Sergio Bertolotti
Posts: 54
Joined: Tue 02 May 2006 12:03
Location: Italy

DefaultValues of TMSQuery info

Post by Sergio Bertolotti » Mon 28 Apr 2008 09:40

Dear Support,

I use last version of SDAC 4.x prof and Delphi 2007 with last service pack on MS Vista business with sp 1 in italian language.

I have a simple question...

With Delphi I create a simple project with a TMSConnection, TMSQuery,TDatasource,TDBNavigator and a TDBGrid .

I set with MSQuery editor SQL property : select * from and with your editor I generate Insert/Update/delete and Refresh statemnents.
After this I set options - DefaultValues of TMSQuery - equal true and compile my project.
I have a 3 fields :

FIELD1 type Bits/boolean default value 0
FIELD2 type datetime default value getdate()
FIELD3 type varchar(30) default value user_name()

I run my project and when I insert a record with Insert I see correctly the default value.
When I Edit a record and then Post value I don't see any changes in my 3 fields. In details FIELD2 is the same, the time is not changed...

Is it correct ?

Best regards.

Sergio Bertolotti

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 29 Apr 2008 09:24

Default values are used on new record inserting when the field value is not provided. If you want to set the default field value on update, you should provide the default keyword in your queries instead of the field value. Please, take a look at this post for more information.

Sergio Bertolotti
Posts: 54
Joined: Tue 02 May 2006 12:03
Location: Italy

Post by Sergio Bertolotti » Tue 29 Apr 2008 15:24

Dear Antaeus,

many thank's for your answer.

Best regards.

Sergio Bertolotti

Post Reply