Ryan Thomas

Ryan Thomas

  • NA
  • 13
  • 16.3k

sql select command where CustomerId LIKE textbox.text

Aug 2 2010 6:23 PM
i'm attempting to use a select statement which retrieves products 'LIKE' textbox.text. However, i am given an error and cannot find a solution
 
private
void buttonSearch_Click(object sender, EventArgs e)
{
if (radioButtonCustomerID.Checked == true)
{
try
{
sqlConnectionNW.Open();
sqlDataAdapterSearch.SelectCommand =
"SELECT * FROM Customers WHERE (CustomerID LIKE'" + textBoxSearch.Text + "')";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlConnectionNW.Close();
}
}
the eror given is "cannot implicitly convert type 'string' to 'System.Data.SqlClient.SqlCommand"
Any help would be highly appreciated as it has stopped me dead in my tracks
thanks

Answers (5)