asp.net.ph

DataTableCollection.Add Method

System.Data Namespace   DataTableCollection Class


Adds a DataTable to the collection.

Overload List

1. Creates a new DataTable object with a default name and adds it to the collection.

2. Adds the specified DataTable to the collection.

3. Creates a DataTable object with the specified name and adds it to the collection.


Example

The following example adds a DataTable with the given name to the DataTableCollection.

NOTE: This example uses one of the overloaded versions of Add. For other examples that may be available, see the individual overload topics.

private void AddTable ( DataSet ds ) {
   DataTableCollection myTables = ds.Tables;
   // add a new table with a given name.
   DataTable myTable = myTables.Add ( "myNewTable" );
   myTable.Columns.Add ( "ID", typeof ( int ) );
   myTable.Columns.Add ( "Name", typeof ( string ) );
   Response.Write ( myTables.Count.ToString ( ) );
}
  C# VB

See Also

DataTableCollection Members Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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