int num;
 m_pRecordset.CreateInstance(__uuidof(Recordset));
 CString strSql;
 strSql.Format("select count(*) form xxx where id=1 );
 BSTR bstrSQL=strSql.AllocSysString();
 m_pRecordset->Open(bstrSQL,(IDispatch *)m_pConnection,adOpenStatic,adLockOptimistic,adCmdText);

解决方案 »

  1.   


    CString ctemp = (TCHAR *)(_bstr_t)m_pRecordset->GetFields()->GetItem((long)i)->Value;
    //或者
    CString ctemp=(TCHAR *)(_bstr_t)m_pRecordset->GetCollect("xxxx");
      

  2.   


    我的sql查询判断是这样的if   exists   (select * from dbo.sysobjects where id = object_id('dbo.ClsLpCalCoef') and  objectproperty(id, 'IsUserTable') = 1)
    select   0
    else
    select  1
    要是用CString ctemp=(TCHAR *)(_bstr_t)m_pRecordset->GetCollect("xxxx");
    这个xxxx应该是什么呢
      

  3.   

    我的sql查询判断是这样的if exists (select * from dbo.sysobjects where id = object_id('dbo.ClsLpCalCoef') and objectproperty(id, 'IsUserTable') = 1)
    select 0
    else
    select 1
    那你就改成 
    select 0 as value
    else
    select 1 as valueCString ctemp=(TCHAR *)(_bstr_t)m_pRecordset->GetCollect("value");
      

  4.   

    _variant_t var = m_pRecordset->GetCollect((long)0);
    long lCount = var; // lCount就是你要数
      

  5.   

    strSql.Format("select top %d %s as guid,gaxb,zt,nr,convert(varchar(100),fsrq,21) createdate from %s where %s>'%s' order by guid",g_IniSettings.nRetRows,strGuid,strTable,strGuid,szNum);
    CADOCommand adoCmd_report(g_db_report,strSql,CADOCommand::CmdText);
    CADORecordset adoRs_report(g_db_report);

    if (!adoRs_report.Execute(&adoCmd_report))
    {
    strTmp.Format("Ñо¿ÖÐÐÄÊý¾Ý¿â²éѯʧ°Ü");
    AppendLog(strTmp);
    bLogin=FALSE;
    continue;
    }
    if(adoRs_report.GetRecordCount()<=0)
    {
    adoRs_report.Close(); 
    Sleep(5);
    continue;
    } else
    adoRs_report.MoveFirst();

    for (int i =0;!adoRs_report.IsEof();adoRs_report.MoveNext(),i++,lPost++)
    {
    CString strValue,strDate,strGrupName,strSummary,strCon;
    char* lpContent=NULL;
    DWORD dwTmp=WaitForSingleObject(event_stop,0);
    if (dwTmp==WAIT_OBJECT_0)
    {
    g_update_finish=TRUE;
    g_update_stop=TRUE;
    EnableCtrl(TRUE);
    GetDlgItem(IDCANCEL)->EnableWindow(TRUE);
    return TRUE;
    }
    memset(&szICInfo,0,sizeof(ItemChildInfo)); adoRs_report.GetFieldValue("createdate",strValue);
    strDate=strValue.Left(10); //È¡³öymd È磺2007£­03£­23
    strDate.Replace("-",""); strcpy(szICInfo.szIssueYmd,strDate); //IssueYmd
    szICInfo.szIssueYmd[8]=0; strValue.Delete(0,10);
    strValue.TrimLeft();                     //Çå³þ×Ö·û´®×ó±ßµÄ¿Õ¸ñ
    strDate.Empty();
    strDate=strValue.Left(8);
    strDate.Replace(":","");
    strcpy(szICInfo.szIssueHms,strDate); //IssueHms
    szICInfo.szIssueHms[6]=0; adoRs_report.GetFieldValue("zt",strValue);//µÃµ½Ö÷Ìâ
    strcpy(szICInfo.szTitle,strValue); adoRs_report.GetFieldValue("guid",strValue);//µÃµ½×Éѯ±àºÅ
    strcpy(szNum,strValue);
    WritePrivateProfileString(szAppName,szKeyName,szNum,szIniDir); adoRs_report.GetFieldValue("gaxb",strValue);//µÃµ½×÷Õß
    strcpy(szICInfo.szAuthor,strValue);

    szICInfo.nContentID = lPost; szICInfo.nInfoLevel=nLevle;//×ÊѶµÈ¼¶ adoRs_report.GetFieldValue("nr",strSummary);//ÄÚÈÝ
    strCon.Format("<br>%s</br>" , strSummary);


    if (atoi(szICInfo.szIssueYmd)<lDelDay)
    {
    continue;
    }
    szICInfo.nContentType=0;
    szICInfo.nContentSize=strCon.GetLength();
    //////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////// strTmp=szICInfo.szIssueYmd;
    strTmp1.Format("%s\\%s",szItemChildData,strTmp.Left(6));
    CreateDirectory(strTmp1,NULL);
    strTmp1.Format("%s\\%s\\%ld",szItemChildData,strTmp.Left(6),lPost);
    strcpy(szICInfo.szContentID,szPost);

    strCon.Replace("\r\n","<br>");
    strCon.Replace("\n","<br>");
    memset(szICInfo.szAttachFile,0,sizeof(szICInfo.szAttachFile));
    WriteConToFile(strCon,strTmp1,szICInfo.nContentType);
    //////////////////////////////////////////////////////////////////////////
    strKey.Format("%d",szICInfo.szContentID);
    if (mapString.Lookup(strKey,strMap))
    {
    WriteTitleIni(szItemChildCfg,szICInfo,strMap.GetBuffer(30));
    strMap.ReleaseBuffer();
    }
    else
    WriteTitleIni(szItemChildCfg,szICInfo);
    }
      

  6.   

    自己的一个查询函数,以及取值,可能涉及到多种数据值的处理。 strSql.Format("select top %d %s as guid,gaxb,zt,nr,convert(varchar(100),fsrq,21) createdate from %s where %s>'%s' order by guid",g_IniSettings.nRetRows,strGuid,strTable,strGuid,szNum);
    CADOCommand adoCmd_report(g_db_report,strSql,CADOCommand::CmdText);
    CADORecordset adoRs_report(g_db_report);

    if (!adoRs_report.Execute(&adoCmd_report))
    {
    strTmp.Format("Ñо¿ÖÐÐÄÊý¾Ý¿â²éѯʧ°Ü");
    AppendLog(strTmp);
    bLogin=FALSE;
    continue;
    }
    if(adoRs_report.GetRecordCount()<=0)
    {
    adoRs_report.Close(); 
    Sleep(5);
    continue;
    } else
    adoRs_report.MoveFirst();

    for (int i =0;!adoRs_report.IsEof();adoRs_report.MoveNext(),i++,lPost++)
    {
    CString strValue,strDate,strGrupName,strSummary,strCon;
    char* lpContent=NULL;
    DWORD dwTmp=WaitForSingleObject(event_stop,0);
    if (dwTmp==WAIT_OBJECT_0)
    {
    g_update_finish=TRUE;
    g_update_stop=TRUE;
    EnableCtrl(TRUE);
    GetDlgItem(IDCANCEL)->EnableWindow(TRUE);
    return TRUE;
    }
    memset(&szICInfo,0,sizeof(ItemChildInfo)); adoRs_report.GetFieldValue("createdate",strValue);
    strDate=strValue.Left(10); //È¡³öymd È磺2007£­03£­23
    strDate.Replace("-",""); strcpy(szICInfo.szIssueYmd,strDate); //IssueYmd
    szICInfo.szIssueYmd[8]=0; strValue.Delete(0,10);
    strValue.TrimLeft();                     //Çå³þ×Ö·û´®×ó±ßµÄ¿Õ¸ñ
    strDate.Empty();
    strDate=strValue.Left(8);
    strDate.Replace(":","");
    strcpy(szICInfo.szIssueHms,strDate); //IssueHms
    szICInfo.szIssueHms[6]=0; adoRs_report.GetFieldValue("zt",strValue);//µÃµ½Ö÷Ìâ
    strcpy(szICInfo.szTitle,strValue); adoRs_report.GetFieldValue("guid",strValue);//µÃµ½×Éѯ±àºÅ
    strcpy(szNum,strValue);
    WritePrivateProfileString(szAppName,szKeyName,szNum,szIniDir); adoRs_report.GetFieldValue("gaxb",strValue);//µÃµ½×÷Õß
    strcpy(szICInfo.szAuthor,strValue);

    szICInfo.nContentID = lPost; szICInfo.nInfoLevel=nLevle;//×ÊѶµÈ¼¶ adoRs_report.GetFieldValue("nr",strSummary);//ÄÚÈÝ
    strCon.Format("<br>%s</br>" , strSummary);


    if (atoi(szICInfo.szIssueYmd)<lDelDay)
    {
    continue;
    }
    szICInfo.nContentType=0;
    szICInfo.nContentSize=strCon.GetLength();
    //////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////// strTmp=szICInfo.szIssueYmd;
    strTmp1.Format("%s\\%s",szItemChildData,strTmp.Left(6));
    CreateDirectory(strTmp1,NULL);
    strTmp1.Format("%s\\%s\\%ld",szItemChildData,strTmp.Left(6),lPost);
    strcpy(szICInfo.szContentID,szPost);

    strCon.Replace("\r\n","<br>");
    strCon.Replace("\n","<br>");
    memset(szICInfo.szAttachFile,0,sizeof(szICInfo.szAttachFile));
    WriteConToFile(strCon,strTmp1,szICInfo.nContentType);
    //////////////////////////////////////////////////////////////////////////
    strKey.Format("%d",szICInfo.szContentID);
    if (mapString.Lookup(strKey,strMap))
    {
    WriteTitleIni(szItemChildCfg,szICInfo,strMap.GetBuffer(30));
    strMap.ReleaseBuffer();
    }
    else
    WriteTitleIni(szItemChildCfg,szICInfo);
    }