System.Data Namespace DataColumn Class
Inititalizes a new instance of the DataColumn class using the specified column name.
[ VB ]
Overloads Public Sub New ( _
ByVal columnName As String _
)
[ C# ]
public DataColumn (
string columnName
);
[ C++ ]
public: DataColumn (
String* columnName
);
[ JScript ]
public function DataColumn (
columnName : String
);
- columnName
- A string that represents the name of the column to be created. If set to a null reference or an empty string ( "" ), a default name will be given when added to the columns collection.
By default, the name given to a column becomes the Caption property value.
The following example initializes a new DataColumn with a specified ColumnName.
private void AddDataColumn ( ) {
DataColumn myColumn = new DataColumn ( "id" );
// set various properties.
myColumn.DataType = System.Type.GetType ( "System.Int32" );
myColumn.Unique = true;
myColumn.AutoIncrement = true;
myColumn.AutoIncrementSeed = 1;
myColumn.AutoIncrementStep = 1;
myColumn.ReadOnly = true;
// add to Columns collection.
myTable.Columns.Add ( myColumn );
}
Private Sub AddDataColumn ( )
Dim myColumn As New DataColumn ( "id" )
' set various properties.
With myColumn
.DataType = System.Type.GetType ( "System.Int32" )
.Unique = True
.AutoIncrement = True
.AutoIncrementSeed = 1
.AutoIncrementStep = 1
.ReadOnly = True
End With
' add to Columns collection.
myTable.Columns.Add ( myColumn )
End Sub |
|
C# |
VB |
DataColumn Members DataColumn Constructor Overload List ColumnName Caption DefaultValue DataTable DataType