Selecting a Subset of Rows
The Select( )
method returns a subset of rows from the
DataTable
and returns the result as a
DataRow
array. The four overloads take optional
arguments specifying the filter criteria, sort order, and
DataViewRowState
of the rows to be returned. The
following example illustrates this concept:
// all rows with order amount > 100, sorted on the order date descending DataRow[] dra = dt.Select("OrderAmount>100.00", "OrderDate DESC");
The following example returns all modified rows in the table:
DataRow[] dra = dt.Select(null, null, DataViewRowState.ModifiedCurrent);
Get ADO.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.