Setting a columns default value

  • Thread starter Thread starter Tim Greenwood
  • Start date Start date
T

Tim Greenwood

Sorry to ask this. I could see several times past where this was asked but
Outlook says the messages are no longer on the server.

How do I get this value in a type dataset?? I see a method for setting
columns to null but default values must be easier to get to than it seems.
 
Tim,

A DataColumn has a DefaultValue property which gets or sets the default
value
Dim dataCol as DataColumn = myDataSet.Tables(0).Columns(0)
dataCol.DefaultValue = <the value you want to set as the default (the type
must match the data type)>

Stephen
 
Tim,

Stephen accurately described how to set a DataColumn's
DefaultValue property. This value is used when you create new
DataRow objects.

A common SQL Server column default is "GetDate()", which SQL
Server evaluates each time the default is referenced. Many back
ends support both static values and expressions, like GetDate.
The ADO.NET DefaultValue property only supports static values and
does not fetch column default information from the database.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
Back
Top