读书人

新手

发布时间: 2012-01-19 00:22:28 作者: rapoo

新手求助
SQL语句:select * from EmployyInfo where EmployyId =1
SqlCommand command = new SqlCommand( "select * from EmployyInfo where ' "+this.comboBox1.text+ " '= ' "+this.textBox1.Text+ " ' ", MyCon);
当我在combobox1中输入 "EmployyId " 在this.textbox1.text中输入 "1 "时 我想检索 EmployyInfo表中EmployyId为1 的记录 这条语句不能实现.
要怎么写呢?谢谢

[解决办法]
去掉单引号
[解决办法]
SqlCommand command = new SqlCommand( "select * from EmployyInfo where "
+ this.comboBox1.text + "= ' "+this.textBox1.Text+ " ' ", MyCon);

这样可以了

读书人网 >C#

热点推荐