简单号码搜索问题 [英] Simple number search question
问题描述
我在尝试搜索任何3位数字时遇到麻烦.我正在C#中使用OleDbCommand.
这是我要开始使用的查询.
字符串查询="SELECT \" System.ItemPathDisplay \; FROM \"SystemIndex \"其中包含(\'[0-9] [0-9] [0-9] \')AND scope = \'file:\'AND System.FileName LIKE \'%.%\''';;
但当我这样做时
OleDbCommand命令= new OleDbCommand(查询,conn);
OleDbDataReader WDSResults = command.ExecuteReader();
我在ExecuteReader上获取异常.我猜我没有正确格式化我的contains子句.
非常感谢您.
Gene
包含"除通配符外不支持任何其他内容-它不是正则表达式匹配器:
http://msdn.microsoft.com/zh-cn/library/bb231270(VS.85).aspx
支持正则表达式的唯一谓词是LIKE谓词:
http://msdn.microsoft.com/en-us/library/bb231261 (VS.85).aspx
此外,请记住,LIKE谓词-尤其是如您在此处那样使用时:往往很慢,因为查询的其余部分没有限制.
希望这会有所帮助,
Andrei
>
I'm having trouble trying to search for any 3 digit number. I'm using OleDbCommand in C#.
Here is the query that I'm trying to get to work.
string query = "SELECT \"System.ItemPathDisplay\" FROM \"SystemIndex\" WHERE CONTAINS(\'[0-9][0-9][0-9]\') AND scope=\'file:\' AND System.FileName LIKE \'%.%\'";
but when I do
OleDbCommand command = new OleDbCommand(query, conn);
OleDbDataReader WDSResults = command.ExecuteReader();
I get an exception on the ExecuteReader. I'm guessing that I'm not formatting my contains clause correctly. Is there some documentation somewhere on how I can do regular expression search?
thank you so much.
Gene
"Contains" doesn't support anything except wildcards - it is not a regular expression matcher:
http://msdn.microsoft.com/en-us/library/bb231270(VS.85).aspx
The only predicate that supports regular expressions is LIKE predicate:
http://msdn.microsoft.com/en-us/library/bb231261(VS.85).aspx
Also, have in mind that the LIKE predicate - especially if used like you did here: "LIKE \'%.%\'" tends to be slow, since the rest of the query is so unrestrictive.
Hope this helps,
Andrei
这篇关于简单号码搜索问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!