Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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.

SQL
cmd.CommandText = "Select Locationfrom UsersInfo where " +
               "Location like @SearchText + '%'";


Thanks.
Posted

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
 
Share this answer
 
v2
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.
SQL
cmd.CommandText = "Select Locationfrom UsersInfo where " +
"(Location like @SearchText + '%') AND (Username = 'test') AND (Designation like @Designation + '%')";



I this help, please mark as answer.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900