Ryan Thomas

Ryan Thomas

  • NA
  • 13
  • 21.2k

sql select error

Aug 2 2010 8:28 PM

i've created a select command which then fills a dataset, the input comes from a textbox but when i run the program and searc, i have an error.
private
void buttonSearch_Click(object sender, EventArgs e)
{
if (radioButtonCustomerID.Checked == true)
{

try

{
string selectString = "SELECT * FROM Customers WHERE CustomerID LIKE" + textBoxSearch.Text + "";
SqlCommand myCommand = sqlConnectionNW.CreateCommand();
myCommand.CommandText = selectString;
sqlDataAdapterSearch.SelectCommand = myCommand;
sqlConnectionNW.Open();
sqlDataAdapterSearch.Fill(dataSetSearch);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlConnectionNW.Close();
}
}
}
the error i receive once the button is clicked is : an expression of non-boolean type specified in a context where a condition is expected, near 'LIKE'
 
any help on the problem would be appreciated
thanks

Answers (2)