System.Data Namespace DataTable Class
Returns an array of all DataRow objects that match the filter criteria in order of primary key ( or lacking one, order of addition. )
[ VB ]
Overloads Public Function Select ( _
ByVal filterExpression As String _
) As DataRow ( )
[ C# ]
public DataRow [ ] Select (
string filterExpression
);
[ C++ ]
public: DataRow* Select (
String* filterExpression
) [ ];
[ JScript ]
public function Select (
filterExpression : String
) : DataRow [ ];
- filterExpression
- The criteria to use to filter the rows.
An array of DataRow objects.
To create the filterExpression argument, use the same rules that apply to the DataColumn class's Expression property value for creating filters.
The following example uses a filter expression to return an array of DataRow objects.
private void GetRowsByFilter ( )
// presuming the DataTable has a column named Date.
string strExpr = "Date > '1/1/00'";
DataTable myTable = myDataSet.Tables [ "Orders" ];
// use the Select method to find all rows matching the filter.
DataRow [ ] foundRows = myTable.Select ( strExpr );
// print column 0 of each returned row.
for ( i = 0; i < foundRows.Length; i ++ ) {
Response.Write ( foundRows [ ] [ 0 ] );
}
}
Private Sub GetRowsByFilter ( )
' presuming the DataTable has a column named Date.
Dim strExpr As String = "Date > '1/1/00'"
Dim myTable As DataTable = myDataSet.Tables ( 0 )
' Use the Select method to find all rows matching the filter.
Dim foundRows ( ) As DataRow = myTable.Select ( strExpr )
Dim i As Integer
' print column 0 of each returned row.
For i = 0 to Ubound ( foundRows )
Response.Write ( foundRows ( i ) ( 0 ) )
Next i
End Sub |
|
C# |
VB |
DataTable Members DataTable.Select Overload List CaseSensitive Expression DataRow