dr.Read() 有返回值的,你确定为true吗,一般取值dr.GetString(0) 更好吧,FieldCount和是否读到值没有关系

解决方案 »

  1.   

    你这样试试:
    dr["字段名"].tostring();
    如果用你那个方法,好象应该是dr[0].getstring();才对。
      

  2.   

    先判断一下
    if(dr.Read())
    {
       ……
       string a = dr[0].ToString();
       ……
    }
      

  3.   

    写错了。应该是dr.getstring(0)。或者用我上面说的第一中方式。另外,还应该在取值前进行判断if(dr.read())
    {
    取值代码
    }
      

  4.   

    先判断read():
    while(dr.Read())
    {
       xxx=dr[0].ToString();
    }
      

  5.   

    while(dr.read())
    {
    //********
    // your operation here 
    //********
    }
    //dr has got the end of the datatable
      

  6.   


    dr.GetValue(Pos);
    其中Pos是表中列值,该值从0开始!