Clear Method

DataTableCollection.Clear Method ()


Clears the collection of all DataTable objects.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public void Clear()

To remove a particular DataTable from the collection, use the Remove method.

The following example gets the DataTableCollection of a DataSet, and then clears the collection of all tables.

private void ClearTables()
    // Get the DataSet of a DataGrid control.
    DataSet dataSet = (DataSet)DataGrid1.DataSource;
    DataTableCollection tables = dataSet.Tables;

    // Clear the collection.

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft