Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I initialize ADO in the ATL COM ?

Status
Not open for further replies.

zyhu

Programmer
Aug 22, 2000
21
0
0
CN
When I initialize ADO in the ATL COM with the following:

ADODB::_ConnectionPtr pConn;
pConn.CreateInstance(__uuidof(ADODB::Connection));

but the result is that the interface pointer pConn is NULL. Why?
 
I think you should assign the result of your code to some variable. I'm not too strong with ATL though just read about lightly.
 
Recently I found the following returned with the smart pointer successfully in Win98 but failed in WinNT4.0.
ADODB::_ConnectionPtr pConn;
pConn.CreateInstance(__uuidof(ADODB::Connection));

I don't know why it is.
 
If use ADO to access database,the MDAC must be installed in the WinNT.
The following is used to initial ADO in the ATL COM:

_ConnectionPtr pObjADO_Connection = NULL;
hr = pObjADO_Connection.CreateInstance(__uuidof(Connection));
hr = pObjADO_Connection->Open( _bstr_t (L
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top