代码如下:
BOOL CAdoConnection::Connect()
{ CString strDBName;
strDBName="account";
m_pConnection.CreateInstance("ADODB.Connection");
CString strConnection =_T"Provider=Microsoft.Jet.OLEDB.3.5;Data Source=" + strDBName); m_pConnection.Open(strConnection,"","",-1);
return -1;
}错误:
:\vc++源代码\个人代码\实验\newado1\newado1.h(34) : error C2039: 'Open' : is not a member of '_com_ptr_t<class _com_IIID<struct _Connection,&struct __s_GUID  _GUID_00000550_0000_0010_8000_00aa006d2ea4> >'
代码很乱,我是初学者,想请教任何用ADO连数据库?能给出代码最好了,
能详细就更好了啊!我现在就只是想实现连接,和显示数据库中的数据,
希望各位帮帮忙了 ~

解决方案 »

  1.   

    见http://expert.csdn.net/Expert/topic/1571/1571631.xml?temp=.9863397
      

  2.   


    _RecordsetPtr pRst = NULL;
    _ConnectionPtr pConn = NULL;
    pConn.CreateInstance(__uuidof(Connection));
    pConn->Open(m_strCnn,"","",NULL);        
    pRst.CreateInstance(__uuidof(Recordset));
    pRst->Open("SQL语句",_variant_t((IDispatch *)               pConn,true),adOpenKeyset,adLockOptimistic,adCmdTable);