[Solved] SQL query WHERE string LIKE field [closed]


I think the issue is that you have an extra space after the inserted text in the SQL. This means that you are effectively searching for “lblheader.text ” (with a space after it) everytime, which I doubt is what you want.

In the SQL statement , change

LIKE '%"+ lblheader.Text +" %' ";

To

LIKE '%"+ lblheader.Text +"%' ";

On a separate issue

The code above is subject to SQL Injection which is a major security issue for your application. Read more here: http://en.wikipedia.org/wiki/SQL_injection

solved SQL query WHERE string LIKE field [closed]