DataColumn.ColumnName Property
Assembly: System.Data (in system.data.dll)
'Declaration Public Property ColumnName As String 'Usage Dim instance As DataColumn Dim value As String value = instance.ColumnName instance.ColumnName = value
/** @property */ public String get_ColumnName () /** @property */ public void set_ColumnName (String value)
public function get ColumnName () : String public function set ColumnName (value : String)
Property Value
The name of the column.When a DataColumn is created, it has no ColumnName value. However, when the DataColumn is added to a DataColumnCollection for a DataTable object, it is given a default name ("Column1", "Column2", and so on).
By default, the Caption value is set to the ColumnName value.
The following examples gets the ColumnName for every column in every table in a DataSet. The example also shows how to create a DataColumn with a new ColumnName.
Private Sub PrintColumnNames(dataSet As DataSet) Dim table As DataTable Dim column As DataColumn ' For each DataTable, print the ColumnName. For Each table in dataSet.Tables For Each column in table.Columns Console.WriteLine(column.ColumnName) Next Next End Sub Private Sub AddColumn(table As DataTable) Dim column As DataColumn column = New DataColumn() With column .ColumnName = "SupplierID" .DataType = System.Type.GetType("System.String") .Unique = True .AutoIncrement = False .Caption = "SupplierID" .ReadOnly = False End With ' Add the column to the table's 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.