while(dr.Read())
{
   ...code
}

解决方案 »

  1.   

    列名 'xh' 无效。 
    列名 'xni' 无效。 
    列名 'xqi' 无效。 
    列名 'kmu' 无效。
    数据库中有xh、xni、kmu列名么?
      

  2.   

    这些都是参数啊要s_name='"+xh+"' and s_year='"+xni+"' and s_term='"+xqi+"' and s_sort='"+kmu+"'"
    这么写,如果数据库字段是数字的就不要单引号
      

  3.   

    SqlCommand comm = new SqlCommand("select * from scorelist where s_name='xh' and s_year='xni' and s_term='xqi' and s_sort='kmu'", conn
      

  4.   

    这个很糟糕,LZ是否看下书上简单的例子,可能毛病有时就是LZ你的一点点小疏忽
      

  5.   

    什么列名啊,根本就是sql语句写得有问题啊
      

  6.   

    SqlCommand comm = new SqlCommand("select * from scorelist where s_name=xh and s_year=xni and s_term=xqi and s_sort=kmu", conn); 这里不对,建议使用参数
      

  7.   

    SQL写的有问题 select * from xxx where xxx='xxx'
      

  8.   

    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中传值的时候要加  ' 号。不然就不会被识别为字段值,而被误认为是字段名(即列)勒。
      

  9.   

     SqlCommand comm = new SqlCommand("select * from scorelist where s_name='"+xh+"' and s_year='"+xni+"' and s_term='"+xqi+"' and s_sort='"+kmu+"'", conn); 
      

  10.   

    SqlCommand comm = new SqlCommand("select * from scorelist where s_name='"+xh+"' and s_year='"+xni+"' and s_term='"+xqi+"' and s_sort='"+kmu+"'", conn); 
    当然如果是数字字段就取消单引号
      

  11.   

    select * from scorelist where s_name="+ xh +" and s_year= " + xni +"  and s_term=' " + xqi +" 'and s_sort="+ kmu +"
      

  12.   

    建议楼主使用SqlParameter,在数据库中进行拼装SQL 语句。这样能减少错误
      

  13.   

    ("select * from scorelist where s_name='"+xh+"' and s_year=’“+xni+”‘ and s_term='"+xqi+"' and s_sort='"+kmu+", conn); 
    应该可以了