pUserSet->Open("select * from score",theApp.m_pConnection.GetInterFacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);错误说:
error C2228: left of '.m_pConnection' must have class/struct/union type
error C2228: left of '.GetInterfacePtr' must have class/struct/union type
error C2664: 'Open' : cannot convert parameter 1 from 'class CString' to 'const class _variant_t &'
Reason: cannot convert from 'class CString' to 'const class _variant_t'
No constructor could take the source type, or constructor overload resolution was ambiguous
请问是什么原因啊,而且查了另外一本书也是这样用的啊

解决方案 »

  1.   

    theApp.m_pConnection.GetInterFacePtr()
    must change to:
    theApp.m_pConnection->GetInterFacePtr()
      

  2.   

    _bstr_t strCnn("Provider=sqloledb;Data Source=MyServer;Initial Catalog=pubs;User Id=sa;Password=***;");
    _bstr_t strRst("select * from score");
    _ConnectionPtr m_pConnection;
    _RecordSetPtr pUserSet;
    try
    {
      m_pConnection.CreateInstance(__uuidof(Connection));
      m_pConnection->Open(strCnn,"","",adConnectUnspecified);
      pUserSet.CreateInstance(__uuidof(RecordSet));
      pUserSet->Open(strRst,_variant_t((IDispatch *) m_pConnection, true),adOpenKeyset,adLockOptimistic,adCmdTable);
    }
    catch(_com_error &e)
       {
    ...............
    }