DataTable.Select Method (String, String)
.NET Framework 2.0
Gets an array of all DataRow objects that match the filter criteria, in the specified sort order.
Namespace: System.Data
Assembly: System.Data (in system.data.dll)
DataTable Members
System.Data Namespace
CaseSensitive
Assembly: System.Data (in system.data.dll)
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.
The following example uses a filter expression to return an array of DataRow objects.
private void GetRowsByFilter() { DataTable table = DataSet1.Tables["Orders"]; // Presuming the DataTable has a column named Date. string expression = "Date > '1/1/00'"; // Sort descending by column named CompanyName. string sortOrder = "CompanyName DESC"; DataRow[] foundRows; // Use the Select method to find all rows matching the filter. foundRows = table.Select(expression, sortOrder); // Print column 0 of each returned row. for(int i = 0; i < foundRows.Length; i ++) { Console.WriteLine(foundRows[i][0]);
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
DataTable ClassDataTable Members
System.Data Namespace
CaseSensitive