Returns an array of all DataRow objects that match the filter criteria, in the the specified sort order.
[Visual Basic] 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[];
An array of DataRow objects matching the filter expression.
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.
[Visual Basic]
Private Sub GetRowsByFilter() Dim t As DataTable t = DataSet1.Tables(0) ' Presuming the DataTable has a column named Date. Dim strExpr As String Dim strSort As String strExpr = "Date > 1/1/00" strSort = "CompanyName DESC" Dim foundRows() As DataRow ' Use the Select method to find all rows matching the filter. foundRows = t.Select(strExpr, strSort) Dim i As Integer ' Print column 0 of each returned row. For i = 0 to Ubound(foundRows) Console.WriteLine(foundRows(i)(0)) Next i End Sub
DataTable Class | DataTable Members | System.Data Namespace | DataTable.Select Overload List | CaseSensitive | Expression | DataRow