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 ()

Creates a new table with a default name and adds it to the collection.

[Visual Basic]
Overloads Overridable Public Function Add() As DataTable
[C#]
public virtual DataTable Add();
[C++]
public: virtual DataTable* Add();
[JScript]
public function Add() : DataTable;

Return Value

The newly created DataTable.

Remarks

Because no name is specified, the table is created with a default name, relative to its order of addition. The default name is "Table<i>" where i = a new 1-based index.

The OnCollectionChanged event occurs when a table is successfully added to the collection.

Example [Visual Basic]

The following example adds three new DataTable objects to the TablesCollection using the Add method with no arguments.

[Visual Basic]

Private Sub AddTables()
   Dim t As DataTable
   Dim dSet As DataSet
   ' Presuming a DataGrid is displaying more than one table, get its DataSet.
   Set dSet = DataGrid1.DataGridTable.DataTable.DataSet
   Dim i As Integer
   For i = 0 to 2
      dSet.Tables.Add
   Next i
   MessageBox.Show dSet.Tables.Count & " tables"
   For Each t In dSet.Tables
      MessageBox.Show t.TableName
   Next
End Sub

See Also

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