recordsetPtr的open方法 什么时候会一次返回所有记录到内存?
经常出现异常,错误消息为 对象已经使用  是怎么回事啊?

解决方案 »

  1.   

    不会一次返回所有记录,只能通过你的程序循环读取。
      pRs->Open("SELECT * FROM Employee ORDER BY lname", 
             "dsn=pubs;uid=sa;pwd=;", 
             adOpenStatic, adLockOptimistic, adCmdText);
          
          TESTHR(picRs->BindToRecordset(&rs));      while (!pRs->EndOfFile)
             {
          // Process data in the CCustomRs C++ instance variables.
             printf("Name = %s %s\n",
                (rs.m_ul_fnameStatus == adFldOK ? rs.m_ch_fname: "<Error>"), 
                (rs.m_ul_lnameStatus == adFldOK ? rs.m_ch_lname: "<Error>"));      // Move to the next row of the Recordset. 
          // Fields in the new row will automatically be 
          // placed in the CCustomRs C++ instance variables.
       
             pRs->MoveNext();
             }
      

  2.   

    这个recordsetPtr你有没有CLOSE?    if (pRstEmployee)
            if (pRstEmployee->State == adStateOpen)
                pRstEmployee->Close();
        if (pConnection)
            if (pConnection->State == adStateOpen)
                pConnection->Close();