System.Data Namespace DataTableCollection Class
Checks whether a specified table can be removed from the collection.
[ VB ]
Overloads Public Function CanRemove ( _
ByVal table As DataTable _
) As Boolean
[ C# ]
public bool CanRemove (
DataTable table
);
[ C++ ]
public: bool CanRemove (
DataTable* table
);
[ JScript ]
public function CanRemove (
table : DataTable
) : Boolean;
- table
- The DataTable object to check.
true if the table can be removed; otherwise, false.
The following example uses the CanRemove method to test whether each table can be removed from a DataSet. If so, the Remove method is called.
private void RemoveTables ( DataSet ds ) {
// get the DataTableCollection.
DataTableCollection myTables = ds.Tables;
DataTable tbl;
while ( myTables.Count > 0 ) {
tbl = myTables [ 0 ];
if ( myTables.CanRemove ( tbl ) ) myTables.Remove ( tbl );
}
}
Private Sub RemoveTables ( )
' get the DataTableCollection.
Dim myTables As DataTableCollection = ds.Tables
Dim tbl As DataTable
Do While myTables.Count > 0
tbl = myTables ( 0 )
If myTables.CanRemove ( tbl ) Then myTables.Remove ( tbl )
Loop
End Sub |
|
C# |
VB |
DataTableCollection Members Clear Remove RemoveAt