ado| Data | statement
1, the use of wildcard characters
In ADO. NET allows you to use wildcard characters for data queries. As in the following statement query table EmployeeID All data starting with a
Select employeeid,employname,tel,salary ... where employeeid= ' a% ';
Ado. NET allows% or * wildcard characters to be used at the beginning or end of a string. such as the following statement to query the table all the number of numbers in the tail of the document s
Select productcode,productname,productsum,productprice ... where ordercode= '%s '
Ado. NET does not allow the use of separate symbols such as "?", "-" and so on
2, the use of separators
A. Quotes
Be aware of the use of single quotes in ado.net, for example, when querying for a user's name, the user may look for data with the name K ' Leey, at which point the data query statement becomes
Name= ' K ' leey '
When single quotes appear when you query, it should be replaced with two single quotes, that is, name= ' K ' leey ', in practice, when single quotes appear in a data query statement, you can substitute the Replace method of the string class with the "'", as
Condition = "Name= '" +tempname. Replace ("" "," "") + ""
B. Date
You can use the # symbol to process queries in ado.net that involve date formats, as shown in the following example
Condition = "enddate< #2005/09/07# and enddate> #2005/08/07#"
C. Column Separator
When a column in a datasheet contains a column separator for some reason, such as sale order, you can use [] to differentiate this column, as shown in the following example
condition = "[Sale order] = S845647"
In this case, if the data column already contains a column delimiter as part of the column name sale] order[, you need to add the \ symbol before the end of the column separator.
Condition = "[sale\] order[] = S845647"
If you are dealing with this ado.net operation in C #, you need to be aware of the symbolic escape problem, and the example will become
Condition = "[sale\\] order[] = S845647"