有没有一个方法或变量可以得到一个记录集的所有记录数?

解决方案 »

  1.   

    其他的都不安全,建议不要用GetRecordCount函数
      

  2.   

    还有一个办法是直接用先SQL的select count(*) 得到记录数
      

  3.   

    if (m_pRecordset->Supports(adApproxPosition) && m_pRecordset->Supports(adBook))
    {
        return m_pRecordset->RecordCount;
    }
      

  4.   

    谢谢几位, 我用GetRecordCount()和RecordCount都试过,可是都返回-1, 是不是有什么东西要先处理啊!
      

  5.   

    在使用m_pRecordset->Open之前加上这句:
    m_pRecordset->CursorLocation = adUseClient;
      

  6.   

    GetRecordCount之前要用游标设置在客户端
    也可以用select count(*)
      

  7.   

    try
    {
    pRecordset=pConnection->Execute("select count(*) from C_node;",
    NULL,
    adCmdText);
    }
    catch(_com_error *e)
    {
    WarningMsgBox(e->ErrorMessage());
    return false;
    }
    n=pRecordset->GetCollect(_variant_t(long(0)));n就是了