System.Data Namespace DataColumnCollection Class
Adds a DataColumn to the columns collection.
1. Initializes and adds a new DataColumn to the columns collection.
2. Initializes and adds a specified DataColumn object to the columns collection.
3. Initializes and adds a DataColumn with the specified name to the columns collection.
4. Initializes and adds a DataColumn with the specified name and type to the columns collection.
5. Initializes and adds a DataColumn with the specified name, type, and expression to the columns collection.
The following example initializes and adds a new DataColumn to a DataColumnCollection of a DataTable.
NOTE: This example shows how to use one of the overloaded versions of Add. For other examples that may be available, see the individual overload topics.
Private Sub AddColumn ( )
Dim cols As DataColumnCollection
Dim myCol As DataColumn
' get the DataColumnCollection of a table in a DataSet.
cols=ds.Tables ( "Orders" ).Columns
' add a new column and return it.
myCol=cols.Add ( "Total", System.Type.GetType ( "System.Decimal" ), _
"Price + Tax" )
myCol.ReadOnly=True
myCol.Unique=False
End Sub
DataColumnCollection Members