saerch使用多列,请检查我的代码 [英] saerch using multiple columns, please check my code
本文介绍了saerch使用多列,请检查我的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用多列进行搜索。这是自动完成文本框的代码。
顺便说一句,我有多个文本框可以从数据库中搜索。
我有字段作为用户名,位置,指定..我只能搜索位置。
请检查此查询我想搜索3个字段
这是我的代码。
I want to search, using multiple columns. this is the code of autocomplete textbox.
By the way i have multiple textboxes to search from database.
I have fields as Username, Location,Designation..I can only search location.
Please check this query i want to search 3 fields
This is my code.
cmd.CommandText = "Select Locationfrom UsersInfo where " +
"Location like @SearchText + '%'";
谢谢。
Thanks.
推荐答案
sqlstr = "select DOCCODE,DOCNAME,DOCOTHERDTLS from tbl_adm_ms_doctor where docactive<>'I'"
If Len(Trim(code)) <> 0 Then
sqlstr = sqlstr & " AND DOCCODE like'" & code.ToUpper & "%'"
End If
If Len(Trim(desc)) <> 0 Then
sqlstr = sqlstr & " AND DOCNAME like'%" & desc.ToUpper & "%'"
End If
sqlstr = sqlstr & " order by DOCCODE"
cmd.CommandText=sqlstr
此链接可以帮助您:
http://www.w3schools.com/sql/sql_where.asp [ ^ ]
另外,你可以使用AND 和或关键字添加更多过滤器。
This link may help you:
http://www.w3schools.com/sql/sql_where.asp[^]
Also, you can use "AND" and "OR" keywords to add more filters.
cmd.CommandText = "Select Locationfrom UsersInfo where " +
"(Location like @SearchText + '%') AND (Username = 'test') AND (Designation like @Designation + '%')";
我的帮助,请标记为答案。
I this help, please mark as answer.
这篇关于saerch使用多列,请检查我的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文