ObjCommand.CommandText = strSel;
改为:
ObjCommand = new OleDbCommand(strSel, "Provider=...连接字符串");

解决方案 »

  1.   

    你定义的是myReader
    用的时候是while (reReader.Read())
    很明显的错!!!!
      

  2.   

    呵呵,一大堆错误。
    没有联接、更没有打开联接
    还用错了变量,这是个大马虎!
    呵呵,开个玩笑,不会生气吧
    OleDbConnection conn = new OleDbConnection();
    conn.ConnectionText = 联接字符串;
    OleDbCommand ObjCommand;string strSel = "SELECT * FROM WareHouseTable";ObjCommand.CommandText = strSel;
    ObjCommand.Connection = conn;
    OleDbDataReader myReader = ObjCommand.ExecuteReader(); 
    int i=0;
    conn.Open();
    while (myReader.Read())
    {
      this.dtWareHouse.Rows[i]["WareHouseID"]="01";//reReader.GetValue(0);
      this.dtWareHouse.Rows[i]["WareHouseID"]=reReader.GetValue(1);
      this.dtWareHouse.Rows[i]["WareHouseID"]=reReader.GetValue(2);
      i++;
    }
    conn.Close();
      

  3.   

    icyer() :在这之前已经写过连接数据库的语句! 
    srnld(天涯) : 不是定错了,而是“OleDbCommand ObjCommand;
      string strSel = "SELECT * FROM WareHouseTable";
      ObjCommand.CommandText = strSel;
      OleDbDataReader myReader = ObjCommand.ExecuteReader();”写在一个方法里这个方法返回类型为OleDbDataReader
      

  4.   

    你如果是返回的Reader,那么你的Connection就不能关闭,也就是说使用Reader的时候,Connection必须一直开着,否则Reader无效。