Returns an array of all DataRow objects that match the filter in the order of the sort, that match the specified state.
[Visual Basic] Overloads Public Function Select( _ ByVal filterExpression As String, _ ByVal sort As String, _ ByVal recordStates As DataViewRowState _ ) As DataRow () [C#] public DataRow[] Select( string filterExpression, string sort, DataViewRowState recordStates ); [C++] public: DataRow* Select( String* filterExpression, String* sort, DataViewRowState recordStates ) []; [JScript] public function Select( filterExpression : String, sort : String, recordStates : DataViewRowState ) : DataRow[];
An array of DataRow objects.
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 and record state to return an array of DataRow objects.
[Visual Basic]
Private Sub GetRowsByFilter() Dim t As DataTable t = DataSet1.Tables("Orders") ' Presuming the DataTable has a column named Date. Dim strExpr As String Dim strSort As String strExpr = "Date > 1/1/00" Dim recState As DataViewRowState ' strSort = "CompanyName DESC" recState = DataViewRowState.New Dim foundRows() As DataRow ' Use the Select method to find all rows matching the filter. foundRows = t.Select(strExpr, strSort, recState) 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 | DataRow | DataView | DataViewRowState | Expression