System.Data Namespace DataTableCollection Class
Removes a DataTable object with the specified name from the collection.
[ VB ]
Overloads Public Function Remove ( _
ByVal name As String _
) As DataTable
[ C# ]
public DataTable Remove (
string name
);
[ C++ ]
public: DataTable* Remove (
String* name
);
[ JScript ]
public function Remove (
name : String
) : DataTable;
- name
- The name to give the created DataTable.
The newly created DataTable.
Exception Type |
Condition |
DuplicateNameException |
Occurs when a table in the collection has the same name. The comparison is not case-sensitive. |
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 successfully removed 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.
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 DataTableCollection.Remove Overload List Clear RemoveAt