tags:

views:

252

answers:

3

Hi all,

What is wrong with my line below?

table.DefaultView.RowFilter = cmbBox.Text + 'LIKE' + strName";

The line below works fine but is obviously no use.

table.DefaultView.RowFilter = 'FirstName LIKE James';

Thanks

+1  A: 

It could be a problem with spacing

table.DefaultView.RowFilter = cmbBox.Text + " LIKE " + strName;
AlbertEin
A: 

For one, when you do it that way, you aren't adding spaces.

Also, please don't do this for SQL queries if you are. This leaves you open to sql injection attacks (in the web world). Learn parameterized SQL at the very least. If you already know this, please ignore.

Chad Ruppert
+1  A: 

Seems as if you are missing the wildcards?

table.DefaultView.RowFilter = cmbBox.Text + " LIKE '%" + strName + "%'";
Fredrik Mörk
Thanks, worked great.