Search code examples
c#sql-like

c# Help joining textbox value, LIKE and a string variable


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


Solution

  • Seems as if you are missing the wildcards?

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