Default Values properties (table level) not working. Major Bug!!

I am new to SQL Server Express, but this I believe is a bug.

When I create a new row with a dataset, the table columns 'Default Values' properties do not work.

If I use the database tools to insert a new record; those 'Default Values' that are in the column properties do get transposed or inserted into the new row for that particlular column if there is no other imput.

But... if I insert a new row with a dataset; NONE of those 'Default Values' are inserted if there is no value input for that column(s), ALL of those columns recieve a 'NULL' value instead of the 'Default Value'... why

As far as I can tell this applies to all fields types...

Would I have to create a custom trigger and test for NULL fields for those fields and then insert the default values... I just don't understand why this isn't working at the table level.

VS2005 Pro
2.0 Framework


Answer this question

Default Values properties (table level) not working. Major Bug!!

  • Weathertop

    The database's default values are applied when the columns are omitted in the INSERT INTO query. It sounds like the logic you're using to submit your changes include the NULL values in the INSERT INTO query, which means the database columns' default values will not be applied.

    While this may not be the answer you were hoping for, I hope it still proves helpful.



  • bnanajo

    DataSet functionality is independent of SQL Express so I'm redirecting to the .NET Data forum. They should have a better idea about what the expected behavior here is.

    Mike



  • rbreidenstein

    Hello Mike, David,

    You are absolutely right.

    I was *assuming* the default value would/should override the 'Null' value and really didn't take into account the value of 'Null' would have for other people. Whoooooops.

    Thank you

  • Kris B

    But...

    Using the database tools and when inserting a new row; all rows by default have a 'Null' value.
    And if a default value is assigned to a column, then that default value is inserted correctly if that column has a null value. Ok...
     
    So why doesn't this apply for adding new rows with datasets (a null value is still a null value for a new row)

    This is with adding a new row with the new DataGridView.

    I have always thought of a columns Default Value property as a trigger that tests for nulls and inserts the default value if that column has a null value when the new row is created. So I am expecting the database engine to insert the default value for that column, not the dataset when the value inserted into that column is null for a new row. I really don't need a column default property that only works with database tools, that doesn't help me... totally baffled here...

    To make clear what I am doing; I am using SSMSE to assign the Default Value for a column at the table level, so all default values should be handled at the table level...

    I originally thought I could do this with VistaDB and TurboDB (datasets and database/Table/column default values for new rows). Time to go back and do some extra digging...

  • ajbj

    I guess one point of view is that the dataset is actually putting in a 'NULL' value so the database engine is seeing it as an actual input or value and disregarding the Default values properties...

    Anybody have any insight, thoughts or suggestions

    Thanks.

  • Default Values properties (table level) not working. Major Bug!!