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

The SelectCommand accepts an instance of the SqlConnection class, not just the query string.
Try sqlDataAdapterSearch.SelectCommand = new SqlCommand("SELECT * FROM Customers WHERE (CustomerID LIKE'" + textBoxSearch.Text + "')"); Although you may want to look at using parameters to make your code easier to read/debug.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.