Default value not being populated in dataset

B

Bob

I have a CreatedOn field , datetime, which has GetDate() as the default
value in SQL server 2000 table. When I create a new record in the table
itself in enterprise manager, the field gets populated OK, but when I try to
create a new record with a Microsoft datagridview control, I notice that the
datecreated value does not get created. It looks as if the datagridview
insert statements overrides the default value and prevent the default
defined in the table to get written.

Any ideas on how to overcome this? I've looked in the datagridview controls
properties and the dataset properties for this table and don't find anything
simple to let me ensure that on an insert my default value defined in the
table is the one saved.

Any help would be appreciated.

Bob
 
B

Bob

Its a solution but it goes against the most basic rules of using RDBMS that
is, make the database do all the work that you can have it do, so that your
default values and validations are centralized in one location and you DO
NOT do that in your application code.
The fact that .NET works with many different databases is a weak excuse for
not having completed its development right.
If there is this problem that is known there should be a property in the
datatableAdapters or in the dataset definitions, somewhere where it makes
sense and is easily accessible to the developper, to force the default value
of a new column in a dataset or table adapter. There isn't. That a table
adapter should overwrite the default values of the database is stupid in the
first place. The .Net framework could look in the metadata of the tables
being used and find if there is a default value for a column, if there is it
should just not include these fields in the autogenerated insert statement.
Then you would not be getting a null value overwriting your database
defaults.
Just another example of halfbaked reasoning by Microsoft, Oh well. Maybe
sometime in the future they'll get it right and put the emphasis where its
due. On the reliability of the data, instead of on all the unecessary
glitter of so-called userfriendly interfaces.

Anyways, Thanks Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top