Select method
1 |
Select (); |
Complete a query that returns a DataTable back, often we want to continue to search in the query results. Then you can use the Select method to re-query results.
Select method has four overloads, we often use is DataTable.Select(String);
.
Here to talk with a parameter DataTable.Select(String)
:
This String
parameter is defined query type. Equivalent to the WHERE clause in the SQL query language (excluding WHERE), in line with the syntax of SQL language syntax.
I think it is similar sql syntax only.
But I tried not support BETWEEN AND, successful examples For:
1 |
// FromTime and TOTIME DateTime are two types of variables; occurTime is dTable inside the column name; |
The DataTable.Select () method which supports simple filtering and sorting, the conditions do not support sophisticated filtering and sorting. The string must be inside the column names and data, and>, <, =, <> relational operator and the like. A few examples:
1 |
DataRow[] row = Detailtb.Select("WZMC='"+MaterialName+"' and CZ='"+MaterialTexture+" and GG='"+MaterialSpecs+"'"); |
We must pay attention to the problem of single quotes; before me is the variable in double quotes, and has been an error, and later checked the Internet and found that first double quotes and then single quotes; that is, '' variable '';
Original: Big Box Select method