Removes a specified DataTable object from the collection.
Removes the specified DataTable object from the collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Sub Remove(DataTable)
[C#] public void Remove(DataTable);
[C++] public: void Remove(DataTable*);
[JScript] public function Remove(DataTable);
Removes the DataTable object with the specified name from the collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Sub Remove(String)
[C#] public void Remove(string);
[C++] public: void Remove(String*);
[JScript] public function Remove(String);
[Visual Basic, C#] The following example uses the Contains and CanRemove methods to test whether a named table exists and can be removed. If so, the Remove method is called to remove the table.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of Remove. For other examples that might be available, see the individual overload topics.
[Visual Basic] Private Sub RemoveTables() ' Set the name of the table to test for and remove. Dim strName As String = "Suppliers" ' Presuming a DataGrid is displaying more than one table, get its DataSet. Dim dSet As DataSet = CType(DataGrid1.DataSource, DataSet) Dim tablesCol As DataTableCollection = dSet.Tables If tablesCol.Contains(strName) _ And tablesCol.CanRemove(tablesCol(strName)) Then tablesCol.Remove(strName) End If End Sub [C#] private void RemoveTables() { // Set the name of the table to test for and remove. string strName = "Suppliers"; // Presuming a DataGrid is displaying more than one table, get its DataSet. DataSet dSet = (DataSet)DataGrid1.DataSource; DataTableCollection tablesCol = dSet.Tables; if (tablesCol.Contains(strName) && tablesCol.CanRemove(tablesCol[strName])) tablesCol.Remove(strName); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
DataTableCollection Class | DataTableCollection Members | System.Data Namespace