Multiple LIKE separated by OR

I could use some help with a SQL SELECT LIKE command. I have two TextBox'es that I am using as input for two different searches through a SQL database with the result placed in a GridView.

It is important to note that the search can be performed from either TextBox, so I wanted to use the LIKE command separated by an OR expression. But it does not seem to work. I always need to place something in BOTH TextBox'es to get a result.

I am a novice at VB programming and SQL databases. So any assistance is warmly accepted.

Can Textbox1 and Textbox2 contain a value at the same time , or only one of them at the same time?

If textbox1.text<>"" and textbox2<>"" then
strQuery = "SELECT * FROM Table WHERE
Field LIKE %" & Textbox1.text & "% OR Field
LIKE %" & Textbox2.text & "%"
elseif Textbox1.text<>"" end Textbox2.text="" then
strQuery = "SELECT * FROM Table WHERE
Field LIKE %" & Textbox1.text & "%
elseif Textbox1.text="" end Textbox2.text<>"" then
strQuery = "SELECT * FROM Table WHERE
Field LIKE %" & Textbox2.text & "%
endif

This will do the job.

If you don't need all fields from the table, replace the * for the fieldnames separated bij a ,
This will speedup yor query when using larger databases.

Can Textbox1 and Textbox2 contain a value at the same time , or only one of them at the same time?

If textbox1.text<>"" and textbox2<>"" then
strQuery = "SELECT * FROM Table WHERE
Field LIKE %" & Textbox1.text & "% OR Field
LIKE %" & Textbox2.text & "%"
elseif Textbox1.text<>"" end Textbox2.text="" then
strQuery = "SELECT * FROM Table WHERE
Field LIKE %" & Textbox1.text & "%
elseif Textbox1.text="" end Textbox2.text<>"" then
strQuery = "SELECT * FROM Table WHERE
Field LIKE %" & Textbox2.text & "%
endif

This will do the job.

If you don't need all fields from the table, replace the * for the fieldnames separated bij a ,
This will speedup yor query when using larger databases.

Grtz,
Nokkieja

Thank you for the quick reply. I can see how this will work. However, I am building a web application using ASP and VB. I am unsure how to make this fit within those constraints. As I I stated previously I am a mere novice in all of this. Here is a sample of what I see: