SQL Database table field default value and dataset's datatable

I have designed a table in SQL Server 2000 which has a field with a default value expression of 'getdate()', how can I carry that default value expression when i fill the schema of a dataset So everytime I add a datarow inside the datatable in that dataset, i get the current date and time.

thanks.


Answer this question

SQL Database table field default value and dataset's datatable

  • Paulo Faustino

    Hi,


    Just set your dataColumn's DefaultValue property to the current date. eg:

    ' After filling your datatable with an adapter
    Dim dc as DataColumn = datatable.Columns["ColumnName"]
    dc.DefaultValue = Now





    cheers,

    Paul June A. Domag

  • Kenneth Keeley

    yes that's what i have to do. but still it made me state the default value, and it did not get it automatically from the tables schema.

    meaning i have to still define default values in vb.net even though i have defined it in my table design... sigh.

    thanks for the reply.

  • SQL Database table field default value and dataset's datatable