System.Data Namespace DataTableCollection Class
Removes a DataTable from the collection.
1. Removes a specified DataTable from the collection.
2. Removes a DataTable object with the specified name from the collection.
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.
NOTE: This example uses one of the overloaded versions of Remove. For other examples that may be available, see the individual overload topics.
private void RemoveTable ( DataSet ds, string tblName ) {
DataTableCollection myTables = ds.Tables;
// check if the named table exists.
if ( myTables.Contains ( tblname ) ) && myTables.CanRemove ( tblName ) {
myTables.Remove ( tblName );
}
}
Private Sub RemoveTable ( ByVal ds As DataSet, tblName as String )
Dim myTables As DataTableCollection = ds.Tables
' check if the named table exists.
If myTables.Contains ( tblname ) ) and myTables.CanRemove ( tblName ) Then
myTables.Remove ( tblName );
End If
End Sub |
|
C# |
VB |
DataTableCollection Members