这些都是参数啊要s_name='"+xh+"' and s_year='"+xni+"' and s_term='"+xqi+"' and s_sort='"+kmu+"'" 这么写,如果数据库字段是数字的就不要单引号
SqlCommand comm = new SqlCommand("select * from scorelist where s_name='xh' and s_year='xni' and s_term='xqi' and s_sort='kmu'", conn
这个很糟糕,LZ是否看下书上简单的例子,可能毛病有时就是LZ你的一点点小疏忽
什么列名啊,根本就是sql语句写得有问题啊
SqlCommand comm = new SqlCommand("select * from scorelist where s_name=xh and s_year=xni and s_term=xqi and s_sort=kmu", conn); 这里不对,建议使用参数
SQL写的有问题 select * from xxx where xxx='xxx'
SqlCommand comm = new SqlCommand("select * from scorelist where s_name=xh and s_year=xni and s_term=xqi and s_sort=kmu", conn); SQL写的有问题。非INT型的列在sql中传值的时候要加 ' 号。不然就不会被识别为字段值,而被误认为是字段名(即列)勒。
SqlCommand comm = new SqlCommand("select * from scorelist where s_name='"+xh+"' and s_year='"+xni+"' and s_term='"+xqi+"' and s_sort='"+kmu+"'", conn);
SqlCommand comm = new SqlCommand("select * from scorelist where s_name='"+xh+"' and s_year='"+xni+"' and s_term='"+xqi+"' and s_sort='"+kmu+"'", conn); 当然如果是数字字段就取消单引号
select * from scorelist where s_name="+ xh +" and s_year= " + xni +" and s_term=' " + xqi +" 'and s_sort="+ kmu +"
建议楼主使用SqlParameter,在数据库中进行拼装SQL 语句。这样能减少错误
("select * from scorelist where s_name='"+xh+"' and s_year=’“+xni+”‘ and s_term='"+xqi+"' and s_sort='"+kmu+", conn); 应该可以了
列名 'xni' 无效。
列名 'xqi' 无效。
列名 'kmu' 无效。
数据库中有xh、xni、kmu列名么?
这么写,如果数据库字段是数字的就不要单引号
当然如果是数字字段就取消单引号
应该可以了