我的CRecordset::GetRecordCount函数总返回1,实际上我的记录集里面有很多条记录。如何解决?请给出代码。 谢谢了。

解决方案 »

  1.   

    while(!m_pSet->eof)
    {
    m_pSet->MoveNext();
    }
    long count=m_pSet->GetRecordCount();
    ---------------------
    Caution   The record count is maintained as a “high water ” — the highest-numbered record yet seen as the user moves through the records. The total number of records is only known after the user has moved beyond the last record. For performance reasons, the count is not updated when you call MoveLast. To count the records yourself, call MoveNext repeatedly until IsEOF returns nonzero. Adding a record via CRecordset:AddNew and Update increases the count; deleting a record via CRecordset::Delete decreases the count. 
      

  2.   

    我也遇到过,不知什么原因,最后没办法了,只好用movefirst,movenext.
    学习。