asp.net.ph

DataTableCollection.Remove Method ( String )

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;

Parameters

name
The name to give the created DataTable.

Return Value

The newly created DataTable.

Exceptions


Exception Type Condition
DuplicateNameException Occurs when a table in the collection has the same name. The comparison is not case-sensitive.

Remarks

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.

Example

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 );
   }
}
  C# VB

See Also

DataTableCollection Members   DataTableCollection.Remove Overload List   Clear   RemoveAt Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph