请教各位高手: 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);
 
现在想把查询到的数赋给变量 num,请问这个怎么实现啊?

解决方案 »

  1.   

    SQL没问题,不过怎么将结果集赋值给你定义的那个变量啊,这个我真不知道。你最好去VC板块问一下。不过我刚刚帮你去VC板块逛了一圈,得出结论
    m_pRecordset->Open(bstrSQL,(IDispatch *)m_pConnection,adOpenStatic,adLockOptimistic,adCmdText);num= m_pRecordset->GetCollect("STATUS");这里这个STATUS是你的字段名