asp.net.ph

DataTableCollection.Remove Method ( DataTable )

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
);

Parameters

table
The DataTable object to remove.

Exceptions


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.

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 succefully removed from the collection.

Example

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 );
      }
    }
}
  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