如果查询得到的一个记录集Rst不为空,可以正确的处理数据;若查询得到的数据集Rst为空的话,我们还能对数据集做些什么????GetRecordCount()是调用不得啊!!
该如何判断Rst是否为空?
谢谢

解决方案 »

  1.   

    if(Rst != NULL)
    {
        // do 
    }
      

  2.   

    To:windyloft
    我是指数据集中所包含的记录个数
    Rst!=NULL?????//好像不能用于判断记录个数是否为空吧!
      

  3.   

    if(VARIANT_FALSE == m_pRs->EndOfFile)  //有纪录选出才操作
            {
              ......
            }
      

  4.   

    if (!g_Connection->IsOpen()) 
    {
    return FALSE;
    }

    strQuery = "Select * from GroupList";
    g_RecordSet->SetAdoConnection(g_Connection);

    if (g_RecordSet->Open(strQuery) == -1) 
    {
    m_strErr = g_RecordSet->GetLastError();
    // AfxMessageBox(m_strErr);
    return FALSE;
    } m_GroupCnt = g_RecordSet->GetRecordCount();

    while(!g_RecordSet->IsEOF())
    {
                ......

    }
      

  5.   

    TO:alon21(飘一族.Alon)、 kvw3000(回家念经)sCondition.Format("Template_Id='%s'","mb001");
    oRecordset->Filter=(LPCSTR)sCondition;
    若是在过滤后的结果为多个记录,则各位的方法运行正确!可是若过滤的结果为0个记录,则对RecordCount/GetRecordCount/MoveFirst/EndOfFile的调用都会出现致命错误;
    现在关键问题是如何才能知道过滤后的记录为0个记录!谢谢各位啊!
      

  6.   

    不会吧,我这样满好的呀
             RecordCount = m_pRecordset->RecordCount;

    if(RecordCount==0)
    {
    return 0;
    }
      

  7.   

    if(Rst->adoEOF==VARIANT_TRUE)
    it means that there is no records in the request;
    also you can use 
       RecordCount = m_pRecordset->RecordCount;

    if(RecordCount==0)
    {
    return 0;
    }
    but before that you must make sure you do the below thing:
    Rst->CursorLocation=adUseClient;