Clears the collection of all DataTable objects.
[Visual Basic] Public Sub Clear() [C#] public void Clear(); [C++] public: void Clear(); [JScript] public function Clear();
To remove a particular DataTable from the collection, use the Remove method.
[Visual Basic, C#] The following example gets the DataTableCollection of a DataSet, then clears the collection of all tables.
[Visual Basic] Private Sub ClearTables() Dim myDataSet As DataSet Dim tablesCol As DataTableCollection ' Get the DataSet of a DataGrid control. myDataSet = CType(DataGrid1.DataSource, DataSet) tablesCol = myDataSet.Tables ' Clear the collection. tablesCol.Clear End Sub [C#] private void ClearTables() { DataSet myDataSet; DataTableCollection tablesCol; // Get the DataSet of a DataGrid control. myDataSet = (DataSet)DataGrid1.DataSource; tablesCol = myDataSet.Tables; // Clear the collection. tablesCol.Clear(); }
[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.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
DataTableCollection Class | DataTableCollection Members | System.Data Namespace