asp.net.ph

DataTableCollection.Add Method ( DataTable )

System.Data Namespace   DataTableCollection Class


Adds the specified DataTable to the collection.

[ VB ]
Overridable Overloads Public Sub Add ( _
   ByVal table As DataTable _
)

[ C# ]
public virtual void Add (
   DataTable table
);

[ C++ ]
public: virtual void Add (
   DataTable* table
);

[ JScript ]
public function Add (
   table : DataTable
);

Parameters

table
The DataTable object to add.

Exceptions


Exception Type Condition
ArgumentNullException Occurs when the value specified for the table is a null reference.
ArgumentException Occurs when the table already belongs to this collection, or belongs to another collection.
DuplicateNameException Occurs when a table in the collection has the same name. The comparison is not case-sensitive.

Remarks

The CollectionChanged event occurs when a table is succefully added to the collection.

Example

The following example initializes a DataTable and adds it to the DataTableCollection of a given DataSet.

private void AddTable ( DataSet ds ) {
   // create a new DataTable.
   DataTable myTable = new DataTable ( );
   myTable.Columns.Add ( "ID", typeof ( int ) );
   myTable.Columns.Add ( "Name", typeof ( string ) );
   // add the table to the DataTableCollection.
   ds.Tables.Add ( myTable );
}
  C# VB

See Also

DataTableCollection Members   DataTableCollection.Add Overload List   Clear   DataTable   Remove 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