Export (0) Print
Expand All

DataColumn Constructor ()

Initializes a new instance of a DataColumn class as type string.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

'Declaration
Public Sub New
'Usage
Dim instance As New DataColumn
public DataColumn ()
public function DataColumn ()

When created, a DataColumn object has no default ColumnName or Caption. When you add it to a DataColumnCollection, a default name ("Column1", "Column2", and so on) will be generated if a name has not been assigned to the ColumnName.

The following example creates a new DataColumn, sets various properties, and adds it to a DataColumnCollection for the DataTable object.

Private Sub AddDataColumn(ByVal table As DataTable)
    Dim column As DataColumn = New DataColumn()

    ' Set various properties.
    With column
       .ColumnName = "id"
       .DataType = System.Type.GetType("System.Int32")
       .AutoIncrement = True
       .AutoIncrementSeed = 1
       .AutoIncrementStep = 1
       .ReadOnly = True
     End With

    ' Add to Columns collection.
    table.Columns.Add(column)
End Sub

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft