asp.net.ph

DataTable.Select Method

System.Data Namespace   DataTable Class


Returns an array of DataRow objects.

Overload List

1. Returns an array of all DataRow objects.

2. Returns an array of all DataRow objects that match the filter criteria in order of primary key ( or lacking one, order of addition. )

3. Returns an array of all DataRow objects that match the filter criteria, in the specified sort order.

4. Returns an array of all DataRow objects that match the filter in the order of the sort, that match the specified state.


Example

The following example uses a filter expression and record state to return an array of DataRow objects.

NOTE: This example uses one of the overloaded versions of Select. For other examples that may be available, see the individual overload topics.

private void GetRowsByFilter ( )
   // presuming the DataTable has a column named Date.
   string strExpr = "Date > '1/1/00'";
   // sort descending by column named CompanyName.
   string strSort = "CompanyName DESC";
   // get only new records.
   DataViewRowState recState = DataViewRowState.New;

   DataTable myTable = myDataSet.Tables [ "Orders" ];
   // use the Select method to find all rows matching the filter.
   DataRow foundRows = myTable.Select ( strExpr, strSort, recState );

   // print column 0 of each returned row.
   for ( i = 0; i < foundRows.Length; i ++ ) {
      Response.Write ( foundRows [ ] [ 0 ] );
   }
}
  C# VB

See Also

DataTable 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