asp.net.ph

DataColumnCollection.Remove Method

System.Data Namespace   DataColumnCollection Class


Removes a column from the collection.

Overload List

1. Removes the specified DataColumn object from the collection.

2. Removes the column with the specified name from the collection.


Example

The following example first uses the Contains method to determine if a particular column exists in the collection. If found, the CanRemove method tests whether the column can be removed. If so, the column is removed with the Remove method.

NOTE: This example shows how to use one of the overloaded versions of Remove. For other examples that may be available, see the individual overload topics.

private void RemoveColumn ( DataSet ds, string colName ) {
   // get the DataColumnCollection from a DataTable in a DataSet.
   DataColumnCollection cols = ds.Tables [ "Orders" ].Columns;
   
   if ( cols.Contains ( colName ) && cols.CanRemove ( cols [ colName ] ) ) {
      cols.Remove ( colName );
   }
}
  C# VB

See Also

DataColumnCollection Members 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