当前位置:编程学习 > C#/ASP.NET >>

asp.net用数据库进行信息查询,为什么会出现列名无效?以下代码中第一个if可以执行为什么第二个if就不行了

?“姓名”“学号”都在一个表里,代码也没差,为什如果用“姓名”查询就会“列名无效”?请教各位,谢谢…… 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(); }
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,