Question

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

Was it helpful?

Solution

Seems as if you are missing the wildcards?

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

OTHER TIPS

It could be a problem with spacing

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top