有错误,但是我查不出来。HELP!
我在一个页面上放了一个DropDownList和一个TextBox,我想用dropdownlist中
选中的值和textbox中输入的值作为条件进行查询。可是页面运行时有错误,提示
是:异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。哪位能帮我看看?我自己查不出来,急啊
代码如下:
void SubmitBtn_Click(Object Sender, EventArgs e) {
SqlConnection myConnection = new SqlConnection((String) ConfigurationSettings.AppSettings["gaowei"]);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from case_info where case_char=" + casechar.SelectedItem.Value + " and county like '%" + county.Text.ToString() + "%'", myConnection);
myConnection.Open();
DataSet ds = new DataSet();
myCommand.Fill(ds);
MyDataGrid.DataSource = ds ;
MyDataGrid.DataBind();
myConnection.Close();
}