日期:2014-05-17  浏览次数:20884 次

新手求助! 条件查询并显示在datagridview中
比如我建了一个表格里面都是学生的信息   现在我要查询成绩是100分的人  并且显示在datagridview中   
是不是直接"select * from student where score="+textbox.text+“”;还是怎么写?
查找之后 怎么写让所有符合条件的显示在datagridview中呢?   谢谢各位大神啦!!!在线等.....

------解决方案--------------------
你可以封装一下..
------解决方案--------------------
引用:
C# code?1234567    SqlConnection con = new SqlConnection(sqlcon);        con.Open();        string strsql = select * from student where score="+textbox.text+“”;        SqlDataAdapter adap……



这个够用了。

引用:
引用:C# code?1234567    SqlConnection con = new SqlConnection(sqlcon);        con.Open();        string strsql = select * from student where score="+textbox.text+“”;    ……


那个是定义的表名。存储查询结果的。
------解决方案--------------------
引用:
引用:sql语句错了
C# code?1string strsql = "select * from CostInfo where 消费内容='" + 消费内容ComboBox.Text + "'";
掉了单引号,你最好使用参数化,网上找下资料,很快就会

谢谢你,我去找下参数化的资料学习下       您能告诉我  为什……

字符串,时间等类型都需要加单引号,数字就不用加了