问题
I have this row filter text: "[Name 1] = '" + forename + "%" + surname + "'"
which fails, but if I put the %
at the beginning or end it's OK. Is there any way to achieve the same result (i.e. "any" string in the middle of the names)?
Full statement is:
dv = new DataView(MyDataTable,
"[Name 1] = '" + forename + "%" + surname + "'",
"", DataViewRowState.CurrentRows);
回答1:
Just a free thougth, try:
dv = new DataView(MyDataTable,
"[Name 1] = '" + forename + "%' AND [Name 1] = '%" + surname + "'",
"", DataViewRowState.CurrentRows);
EDIT: some documentation:
"A wildcard is allowed at the start and end of a pattern, or at the end of a pattern, or at the start of a pattern. [...] Wildcard characters are not allowed in the middle of a string. For example, 'te*xt' is not allowed."
My guess would be it's for performance reasons (?)
来源:https://stackoverflow.com/questions/13289735/can-i-achieve-a-wildcard-in-the-middle-of-a-dataview-rowfilter-command