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:

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...