This documentation is archived and is not being maintained.

DataColumn.AllowDBNull Property

Gets or sets a value indicating whether null values are allowed in this column for rows belonging to the table.

[Visual Basic]
Public Property AllowDBNull As Boolean
public bool AllowDBNull {get; set;}
public: __property bool get_AllowDBNull();
public: __property void set_AllowDBNull(bool);
public function get AllowDBNull() : Boolean;
public function set AllowDBNull(Boolean);

Property Value

true if null values values are allowed; otherwise, false. The default is true.


[Visual Basic, C#, C++] The following example creates a new DataColumn and sets its AllowDBNull property to true.

[Visual Basic] 
Private Sub AddNullAllowedColumn()
 Dim myColumn As DataColumn
 myColumn = New DataColumn("classID", System.Type.GetType("System.Int32"))
 myColumn.AllowDBNull = True
 ' Add the column to a new DataTable.
 Dim myTable As DataTable
 myTable = New DataTable
 End Sub

private void AddNullAllowedColumn(){
    DataColumn myColumn;
    myColumn = new DataColumn("classID", System.Type.GetType("System.Int32"));
    myColumn.AllowDBNull = true;
    // Add the column to a new DataTable.
    DataTable myTable;
    myTable = new DataTable();

void AddNullAllowedColumn(){
    DataColumn* myColumn;
    myColumn = new DataColumn(S"classID", System::Type::GetType(S"System.Int32"));
    myColumn->AllowDBNull = true;
    // Add the column to a new DataTable.
    DataTable* myTable;
    myTable = new DataTable();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataColumn Class | DataColumn Members | System.Data Namespace | Unique