System.Data Namespace DataColumn Class
Sets or retrieves a value indicating whether null values are allowed in this column for rows belonging to the table.
Script |
DataColumn.AllowDBNull [ = true | false ] |
This property accepts or returns only a boolean value: true if null values values are allowed; otherwise, false. The default is true.
The following example initializes a new DataColumn and sets its AllowDBNull property to true.
private void AddNullAllowedColumn ( ) {
DataColumn myColumn = new DataColumn ( "classID",
System.Type.GetType ( "System.Int32" ) );
myColumn.AllowDBNull = true;
// add the column to a new DataTable.
DataTable myTable = new DataTable ( );
myTable.Columns.Add ( myColumn );
}
Private Sub AddNullAllowedColumn ( )
Dim myColumn As New DataColumn ( "classID", _
System.Type.GetType ( "System.Int32" ) )
myColumn.AllowDBNull = True
' add the column to a new DataTable.
Dim myTable As New DataTable
myTable.Columns.Add ( myColumn )
End Sub |
|
C# |
VB |
DataColumn Members Unique