asp.net.ph

DataColumnCollection.Add Method

System.Data Namespace   DataColumnCollection Class


Adds a DataColumn to the columns collection.

Overload List

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.


Example

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
See Also

DataColumnCollection Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph