数据库的记录个数
我使用以下语句打开数据库,
如何获取当前CRecordset中记录的记录个数!!!!F_SQL="Select * from Information Where number='0000000003'";
m_DS.Open(AFX_DB_USE_DEFAULT_TYPE,F_SQL);

解决方案 »

  1.   

    最苯得方法就是
    设置一个整型变量
    用一个循环,遍历一遍
    CRecordset
    例如
     int number=0;
    while(!m_Ds.IsEOF())
    {
        number++;
    }
    这样就可以了,number就是记录的个数了
      

  2.   

    "select count(*) from tbl01"
    应该可以吧。
      

  3.   

    CRecordset::GetRowsetSize()
    Call this member function to obtain the current setting for the number of rows you wish to retrieve during a given fetch.
      

  4.   

    CRecordset::GetRowsetSize()
    Call this member function to obtain the current setting for the number of rows you wish to retrieve during a given fetch.恕我无知,,这是什么意思???CRecordset中没有这个函数!!!
      

  5.   

    if( !m_Ds.BOF())
     m_DS.MoveFirst();while(!m_Ds.IsEOF())
    {
        m_Ds.MoveNext;
    }int nCount = m_Ds.GetCount();对于大数据量的,这种方法不好
      

  6.   

    CRecordset::GetRecordCount()
    就OK吧
      

  7.   

    CString MyCount;
    F_SQL="Select count(*) from Information Where number='0000000003'";
    m_DS.Open(AFX_DB_USE_DEFAULT_TYPE,F_SQL);
    m_DS.GetFieldValue(int(0),MyCount);
    //MyCount 就是你想要得
      

  8.   

    CString strSQL=(_T("select * from tablename"));
    m_pRecordset->Open(CRecordset::dynaset,strSQL)
    while(!m_pRecordset->IsEOF())
    {
    m_pRecordset->MoveNext();
    }
    m_pRecordset->GetRecordCount();
      

  9.   


    HRESULT hr = NOERROR;
    IADORecordBinding *piAdoRecordBinding = NULL;
    _RecordsetPtr rs;
    rs.CreateInstance(__uuidof(Recordset));
    rs->CursorLocation = adUseClient;
    CmaintainlistRs pRs;
    rs->Open("select * from tablename" ,(IDispatch *)M_pConnection,adOpenDynamic, 
    adLockBatchOptimistic, adCmdUnspecified);
    if (FAILED(hr = rs->QueryInterface(__uuidof(IADORecordBinding), (LPVOID *)&piAdoRecordBinding)))
    _com_issue_error(hr);
    if (FAILED(hr = piAdoRecordBinding->BindToRecordset(&pRs)))
    _com_issue_error(hr);rs->RecordCount;
      

  10.   

    CRecordset::GetRecordCount()这是不行的,它统计的是访问过的纪录
    要先遍历,GetRecordCount()才行
    或者
    m_pRecordset->equery();
    m_pRecordset->GetRecordCount();