asp.net.ph

DataTable.Select Method ( String, String )

System.Data Namespace   DataTable Class


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

[ VB ]
Overloads Public Function Select ( _
   ByVal filterExpression As String, _
   ByVal sort As String _
) As DataRow ( )

[ C# ]
public DataRow [ ] Select (
   string filterExpression,
   string sort
);

[ C++ ]
public: DataRow* Select (
   String* filterExpression,
   String* sort
 ) [ ];

[ JScript ]
public function Select (
   filterExpression : String,
   sort : String
) : DataRow [ ];

Parameters

filterExpression
The criteria to use to filter the rows.
sort
A string specifying the column and sort direction.

Return Value

An array of DataRow objects matching the filter expression.

Remarks

To form the filterExpression argument, use the same rules for creating the DataColumn class's Expression property value. The Sort argument also uses the same rules for creating class's Expression strings.

Example

The following example uses a filter expression to return an array of DataRow objects, in the specified sort order.

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

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

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

See Also

DataTable Members   DataTable.Select Overload List   CaseSensitive   Expression   DataRow 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