System.Data.DataColumn
A DataColumn represents a single column (or field) in a DataTable (or in a DataRow).
All columns by default can contain Null values (assuming they are not primary keys.
Creating a DataColumn Object
Dim objDataColumn As System.Data.DataColumn
objDataColumn = New System.Data.DataColumn
objDataColumn.ColumnName = "NameOfColumn"
objDataColumn.DataType = System.Type.GetType("System.String")
Alternatively you can pass the column name and the data type directly to the constructor
Dim objDataColumn As New System.Data.DataColumn("NameOfColumn", GetType(String))
Column DataTypes
objDataColumn.DataType = System.Type.GetType("System.String")
objDataColumn.DataType = System.Type.GetType("System.Int32")
objDataColumn.DataType = System.Type.GetType("System.Boolean")
objDataColumn.DataType = System.Type.GetType("System.DateTime")
objDataColumn.DataType = System.Type.GetType("System.Double")
objDataColumn.DataType = System.Type.GetType("System.Decimal")
objDataColumn.DataType = System.Type.GetType("System.Char")
objDataColumn.DataType = System.Type.GetType("System.TimeSpan")
objDataColumn.DataType = System.Type.GetType("System.Single")
objDataColumn.DataType = System.Type.GetType("System.Int16")
Adding a DataColumn to a DataTable
objDataColumn.MaxLength = 100
objDataTable.Columns.Add(objDataColumn)
Alternatively you can create an implicit DataColumn with the Columns.Add method
With objDataTable.Columns.Add("NameOfColumn", GetType(String))
.MaxLength = 100
End With
'or even
objDataTable.Columns.Add("NameOfColumn", GetType(String)).MaxLength = 100
Creating an Expression
objDataColumn.Expression = "FirstName + LastName"
Properties
| AllowDBNull | A boolean that determines whether null values can be accepted for this column. The default is True. |
| AutoIncrement | A boolean that determines whether this is an auto-incrementing column. |
| AutoIncrementSpeed | The starting value for an auto-incrementing column. |
| AutoIncrementStep | The increment value for an auto-incrementing column. |
| Caption | The caption to be used for this column in the user interface |
| ColumnMapping | The MappingType of this column, which is how this column is rendered as XML. It can be Element, Attribute, SimpleContent or Hidden. |
| ColumnName | The name of this column. |
| Container | An object implementing the IContainer interface that represents the component's container, or a null reference (Nothing in Visual Basic) if the component does not have a site. |
| DataType | The System.Type object that defines the data type of this column. |
| DefaultValue | The default value for this column when a new row is added to the table. |
| DesignMode | |
| Expression | The expression to be used for calculated columns. |
| ExtendedProperties | Returns the PropertyCollection object used to store custom information about the DataColumn. |
| MaxLength | The maximum length of a text column. |
| Namespace | The namespace for this DataTable, used when importing or exporting XML data. |
| Ordinal | The position of this column in the DataColumnCollection |
| Prefix | The XML prefix for the DataTable namespace. |
| ReadOnly | A boolean that determines whether values in this column can be modified after the row has been added to the table. |
| Site | |
| Table | The DataTable this column belongs to. |
| Unique | A boolean that determines whether duplicated values are accepted in this column. |
Methods
| Dispose | |
| GetService | |
| GetType | |
| ToString |
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext