我可以在DataView RowFilter命令的中间获得通配符%吗? [英] Can I achieve a wildcard % in the middle of a DataView RowFilter command?
问题描述
我有以下行过滤器文本:"[名称1] ='" +姓氏+%" +姓氏+'"
失败,但是如果我输入%
开头或结尾都可以.是否有任何方法可以达到相同的结果(即名称中间的"any"字符串)?
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)?
完整的声明是:
dv = new DataView(MyDataTable,
"[Name 1] = '" + forename + "%" + surname + "'",
"", DataViewRowState.CurrentRows);
推荐答案
只是一个自由的想法,请尝试:
Just a free thougth, try:
dv = new DataView(MyDataTable,
"[Name 1] = '" + forename + "%' AND [Name 1] = '%" + surname + "'",
"", DataViewRowState.CurrentRows);
一些文档:
在模式的开头和结尾,或在模式的结尾处或在模式的开头都允许使用通配符.在字符串的中间不允许使用通配符.例如,不允许使用"te * xt"."
"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 (?)
这篇关于我可以在DataView RowFilter命令的中间获得通配符%吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!