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

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

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

Parameters

name
The name to give the created DataTable.

Return Value

The newly created DataTable.

Exceptions

Exception Type Condition
DuplicateNameException A table in the collection has the same name. The comparison is not case-sensitive.

Remarks

If either a a null reference (in Visual Basic Nothing) or an empty string ("") is passed in, a default name is given to the newly created DataTable.

The OnCollectionChanged event occurs if the table is succesfully added.

Example [Visual Basic]

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

[Visual Basic]

Private Sub GetTableByName()
   Dim dSet As DataSet
   Dim dt As DataTable
   ' Presuming a DataGrid is displaying more than one table, get its DataSet.
   Set dSet = DataGrid1.DataGridTable.DataTable.DataSet
   ' Use the Add method to add a new table with a given name.
   Set dt = dSet.Tables.Add("myNewTable")
   ' Code to add columns and rows not shown here.
   MessageBox.Show dt.TableName
   MessageBox.Show dSet.Tables.Count 
End Sub

See Also

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