Possible Duplicate:
how to make search of a string in a data base in c#
I want to search for a name in details .. thats the code for search button
private void button1_Click(object sender, EventArgs e)
{
string connectionString = Tyres.Properties.Settings.Default.Database1ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
DataTable dt = new DataTable();
SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM table1 where Details like" + textBox1.Text, conn);
SDA.Fill(dt);
dataGridView1.DataSource = dt;
}
and this example of my application
I am getting the error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: An expression of non-boolean type specified in a context where a condition is expected, near 'likeelie'.
I have tried this code to search for a integer(like Quantity) it works well for me :
private void button1_Click(object sender, EventArgs e)
{
string connectionString = Tyres.Properties.Settings.Default.Database1ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
DataTable dt = new DataTable();
SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM table1 where Quantity like" + int.parse(textBox1.Text), conn);
SDA.Fill(dt);
dataGridView1.DataSource = dt;
}
so I need a help with the first code