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 [C#] public bool AllowDBNull {get; set;} [C++] public: __property bool get_AllowDBNull(); public: __property void set_AllowDBNull(bool); [JScript] public function get AllowDBNull() : Boolean; public function set AllowDBNull(Boolean);
true if null values values are allowed; otherwise, false. The default is true.
[Visual Basic, 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 myTable.Columns.Add(myColumn) End Sub [C#] 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(); myTable.Columns.Add(myColumn); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
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 - Windows CE .NET
DataColumn Class | DataColumn Members | System.Data Namespace | Unique