ATL Error acessing Oracle (VC++ 6.0)
Good day,
I am currently experiencing the following problem when attempting to
access an Oracle database from ATL out-of-process server. I am using
Microsoft ActiveX Data Objects 2.8 and importing it via the following
commands in stdafx.h:
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll"
rename("EOF", "adoEOF")
#pragma comment(lib, "mpr.lib")
typedef ADODB::_ConnectionPtr ADOConnectionPtr;
typedef ADODB::_RecordsetPtr ADORecordsetPtr;
Once done, I open a connection through the following function:
ADOConnectionPtr OpenConnection(CComBSTR strUsername,
CComBSTR strPassword,
CComBSTR strDatasource)
{
ADOConnectionPtr ptrConn;
try
{
if (FAILED(ptrConn.CreateInstance(__uuidof(ADODB::Connection))))
return NULL;
_bstr_t bsDSN = strDatasource;
_bstr_t bsUsername = strUsername;
_bstr_t bsPassword = strPassword;
if (FAILED(ptrConn->Open(bsDSN,
bsUsername,
bsPassword,
ADODB::adOpenUnspecified)))
{
ptrConn = NULL;
return NULL;
}
return ptrConn;
}
catch (_com_error &ce)
{
ptrConn = NULL;
return NULL;
}
}
No errors or exceptions are reported when calling the function. State
of the connection after calling the function is adOpen. I pass in name
of my datasource "testds" and username and password. "Testds" points to
the OracleDb10g [provided by Oracle] client driver in my Oracle client
directory.
As soon as I attempt to use the pointer to the connection object, I get
the following error:
[Oracle][ODBC][Ora]ORA-03114: not connected to Oracle.
Does this have something to do with the fact that it is an ODBC driver?
Any ideas or help would be much appreciated. PS, I tried using the MFC
CDatabase class to do the same within my ATL EXE Server and got the
same error. From standard MFC dialog based application, the connection
works fine on the same PC in both cases.
Regards,
Carl