strSQL1.Format("select srcIP,sum(flux) as totalFlux from (%s) as Temp group by srcIP" , strSQL);
strSQL是一个语句,之前已经能单独成功得到一个结果集,如:select * from Data,
可是执行strSQL1就是会抛出异常,操作失败,大家帮帮忙!

解决方案 »

  1.   

    你的记录集是不是没有关,然后第二次再查数据的时候又打开一次 报错了你debug一下看看!不行就把代码贴出来,帮你看看
      

  2.   

    strSQL.Format("%s order by revTime",temp);
    m_Ado.GetRecordSet(strSQL);
    while(!m_Ado.m_pRecordset->adoEOF)
    {
    CString s0 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("protocol"));
    CString s1 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("srcIP"));
    CString s2 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("srcPort"));
    CString s3 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("destIP"));
    CString s4 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("destPort"));
    CString s5 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("flux"));
    CString s6 = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("revTime"));
    int index;
    index = m_ListCtrl.InsertItem(0,s0);
    m_ListCtrl.SetItem(index,1,LVIF_TEXT,s1, 0, 0, 0,0);
    m_ListCtrl.SetItem(index,2,LVIF_TEXT,s2, 0, 0, 0,0);
    m_ListCtrl.SetItem(index,3,LVIF_TEXT,s3, 0, 0, 0,0);
    m_ListCtrl.SetItem(index,4,LVIF_TEXT,s4, 0, 0, 0,0);
    m_ListCtrl.SetItem(index,5,LVIF_TEXT,s5, 0, 0, 0,0);
    m_ListCtrl.SetItem(index,6,LVIF_TEXT,s6, 0, 0, 0,0);
    m_Ado.m_pRecordset->MoveNext();
    }   到这边程序都运行出来了,结果也对的
    if(BST_CHECKED == IsDlgButtonChecked(IDC_CHECK7))
    {
    CString strSQL1;
    strSQL1.Format("select srcIP,sum(flux) as totalFlux from (%s) as Temp group by srcIP" , strSQL);
    m_Ado.GetRecordSet(strSQL1);        到这里提示执行Select语句失败
    while(!m_Ado.m_pRecordset->adoEOF)
    {
    CString ip = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("srcIP"));
    CString total_flux = (char*)_bstr_t(m_Ado.m_pRecordset->GetCollect("totalFlux"));
    int index;
    index = m_SrcList.InsertItem(0,ip);
    m_SrcList.SetItem(index,1,LVIF_TEXT,total_flux, 0, 0, 0,0);
    m_Ado.m_pRecordset->MoveNext();
    }
    }
    请大侠指教