System.Data Namespace DataTableCollection Class
Removes a specified DataTable from the collection.
[ VB ]
Overloads Public Sub Remove ( _
ByVal table As DataTable _
)
[ C# ]
public void Remove (
DataTable table
);
[ C++ ]
public: void Remove (
DataTable* table
);
[ JScript ]
public function Remove (
table : DataTable
);
- table
- The DataTable object to remove.
Exception Type |
Condition |
ArgumentNullException |
Occurs when the value specified for the table is a null reference. |
ArgumentException |
Occurs when the table already belongs to this collection, or belongs to another collection. |
To determine if a given table exists and can be removed before invoking Remove, use the Contains and the CanRemove methods.
The CollectionChanged event occurs when a table is succefully removed from the collection.
The following example uses the CanRemove method to test whether each table can be removed from a given DataSet. If so, the Remove method is called to remove the table.
private void RemoveTables ( DataSet ds ) {
while ( ds.Tables.Count > 0 ) {
DataTable table = ds.Tables [ 0 ];
if ( ds.Tables.CanRemove ( table ) ) {
ds.Tables.Remove ( table );
}
}
}
Private Sub RemoveTables ( ByVal ds As DataSet )
While ds.Tables.Count > 0
Dim table As DataTable = ds.Tables ( 0 )
If ds.Tables.CanRemove ( table ) Then
ds.Tables.Remove ( table )
End If
End While
End Sub |
|
C# |
VB |
DataTableCollection Members DataTableCollection.Remove Overload List Clear RemoveAt