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

Removes the table with a specified name from the collection.

[Visual Basic]
Overloads Public Sub Remove( _
   ByVal name As String _
)
[C#]
public void Remove(
   string name
);
[C++]
public: void Remove(
   String* name
);
[JScript]
public function Remove(
   name : String
);

Parameters

name
The name of the DataTable to remove.

Exceptions

Exception Type Condition
IndexOutOfRangeException The collection doesn't have a table at this index.

Remarks

The OnCollectionChanged event occurs when a table is succesfully removed.

To determine if a given table exists and can be removed before invoking Remove, use the Contains and the CanRemove methods.

Example [Visual Basic]

The following example uses the Contains and CanRemove to test whether a named table exists and can be removed. If so, the Remove method is called to remove the table.

[Visual Basic]

Private Sub RemoveTables()
   Dim tablesCol As TablesCollection
   Dim dSet As DataSet
   ' Set the name of the table to test for and remove.
   Dim strName As Integer: strName = "Suppliers"
   ' Presuming a DataGrid is displaying more than one table, get its DataSet.
   Set dSet = DataGrid1.DataGridTable.DataTable.DataSet
   Set tablesCol = dSet.Tables
   If tablesCol.Contains(strName) And tablesCol.CanRemove(strName) Then 
      tablesCol.Remove strName
   End If
End Sub

See Also

TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Remove Overload List | IndexOf | Contains