?“姓名”“学号”都在一个表里,代码也没差,为什如果用“姓名”查询就会“列名无效”?请教各位,谢谢……
if (this.RadioButton1.Checked == true)
{
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("select*from chlesson where 学号=" + this.TextBox1.Text + "", con);
sda.Fill(ds, "chlesson");
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
if (this.RadioButton2.Checked == true)
{
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("select*from chlesson where 姓名=" + this.TextBox2.Text + "", con);
sda.Fill(ds, "chlesson");
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
外面要加一对单引号