I am getting an incorrect syntax error on following code .
There's an error in Sql query ?
protected void btnByName_Click(object sender, EventArgs e)
{string name = txtByName.Text.Trim();
Response.Write("clicked \n");
cmd.Connection = con;
cmd.CommandText = "select * from books where name LIKE '%' "+name+" '%' ";
con.Open();
rdr=cmd.ExecuteReader();
if(rdr.Read())
{Response.Write(" found
");
GridView1.DataSource = rdr;
GridView1.DataBind();
}
else
Response.Write("no match found");
con.Close();
}

Munesh SharmaPosted Aug 29, 2016, 2:28 AM
ketan borsdiyaPosted Aug 29, 2016, 12:49 AM
Bikesh SrivastavaPosted Aug 28, 2016, 11:20 PM
Midhun TpPosted Aug 28, 2016, 10:06 PM
cmd.CommandText = "select * from books where name LIKE '%"+name+"%' ";