NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TablesCollection.Add (DataTable)

Adds the specified table to the collection.

[Visual Basic]
Overloads Overridable 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 to add.

Exceptions

Exception Type Condition
ArgumentNullException The table is a null reference (in Visual Basic Nothing).
ArgumentException The table already belongs to this collection, or belongs to another collection.
DuplicateNameException A table in the collection has the same name. The comparison is not case-sensitive.

Remarks

The OnCollectionChanged event occurs when a table is succefully added.

Example [Visual Basic]

The following example creates a DataTable and adds it to the TablesCollection of a DataSet.

[Visual Basic]

Private Sub AddDataTable()
   Dim tablesCol As TablesCollection
   ' Get the TablesCollection of a DataGrid control's DataSet.
   Set tabelesCol = DataGrid1.DataGridTable.DataTable.DataSet.Tables
   ' Create a new DataTable.
   Dim myTable As DataTable = New DataTable
   ' Code to add columns and rows not shown here.
   
   ' Add the table to the TablesCollection.
   tablesCol.Add myTable
End Sub

See Also

TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Add Overload List | DataTable | Remove | Clear