| hi, string q1 = "select * from register where areaofspecific like ' %+ TextBox1.Text + % ' and experience= '" + DropDownList1.SelectedItem.Value.ToString() + "'"; i wrote the query like this but when i execute the query in sql window the correct result will be displayed i gave the textbox value as .net,sqlin sql table there is c,c++,java,.net,sql but nothing will be displayed what can i do |
Loading
Suthish NairPosted Mar 31, 2011, 10:20 AM
String q1 = "select * from register where areaofspecific like @area and experience = @exp";
Aaron ColenPosted Mar 31, 2011, 9:17 AM
Use '%' + @Parameter + '%' instead of '%@Parameter%'.
Writing '%@Parameter%' the parameter is wrapped in quotes and is interpreted by SQL literally.
karthi vimalaPosted Mar 31, 2011, 9:08 AM
when i used parameterized queries at that time also i didn't get the result
string=q1 = "select * from register where areaofspecific like '%@area%'";
using (SqlCommand cmd = new SqlCommand(q1, conn))
{
cmd.Parameters.AddWithValue("@area", TextBox4.Text);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
}
GridView1.DataSource = ds;
Suthish NairPosted Mar 31, 2011, 7:18 AM