以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [原创]模糊查询只可以查询连在一起的字符,  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=40197)

--  作者:zhangkai0234
--  发布时间:2013/9/11 20:16:00
--  [原创]模糊查询只可以查询连在一起的字符,

南宁市五金交化公司

like "* & txtQry.Text & * 方式的模糊查询只可以查询连在一起的字符,如:“南宁”、“五金交”、“公司”等,而不可以查询“五 交“    宁 市...

 

例如搜索 南宁市五金交化公司

只能输入连在一起的字符如:“南宁”、“五金交”、“公司”等,而不可以查询“五 交“    宁 市...输入出差

如输入 南宁 公司

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("窗口1_Table1")

If
txt = "" Then
    tbl.Filter = ""

Else

    txt=txt.Replace(" ","*")
    txt = "\'*" & txt & "*\'"    \\txt的值为*南宁*公司* 
    tbl.Filter = "客户ID Like " & txt & " Or 公司名称 Like " & txt & " Or 地址 Like " & txt & " Or 联系人 Like " & txt

End

‘txt的值为*南宁*公司*   

出现错误

 

 

[此贴子已经被作者于2013-9-11 20:35:50编辑过]

--  作者:有点甜
--  发布时间:2013/9/11 20:48:00
--  
 比如你要查询 "五 公司"

 就把用空格分隔两个词 五 公司

 然后生成查询条件

 xxx like ’*五*\' and xxx like \'*公司*\'

 这个代码不难实现吧?

--  作者:zhangkai0234
--  发布时间:2013/9/11 20:56:00
--  

哦谢谢,我试试