ATL Server Web service
Hi guys,
i have an ATL Server web service written in C++ and connecting to a SQL database. I noticed the ADO objects do not hold thier state between function calls. After each call, the class member ADO objects do not exist anymore.
section of code is bellow
int InitializeADOComponents()
{
try
{
HRESULT hr = m_connectionPtr.CreateInstance(__uuidof(Connection ));
if(SUCCEEDED(hr))
{
hr = m_commandPtr.CreateInstance(__uuidof(Command));
if(SUCCEEDED(hr))
{
hr = m_recordsetPtr.CreateInstance(__uuidof(Recordset)) ;
if(FAILED(hr))
{
retVal = -1;
}
}
}
catch(...)
{
retVal = 101;
}
return retVal;
}
int OpenDatabaseConnection()
{
try
{
_bstr_t bstrConnection("Provider=sqloledb;Data Source=DSN123;"
"Initial Catalog=Manager;User Id=test;Password=test;");
if(m_connectionPtr)
{
HRESULT hr = m_connectionPtr->Open(bstrConnection,"", "",adConnectUnspecified);
if(FAILED(hr))
{
bConnected = -1;
}
}
}
catch(_com_error er)
{
_bstr_t bs = er.Description();
return 101;
}
return bConnected;
}
This (OpenDatabaseConnection() ) and other ADO method calls after InitializeADOComponents fail because the ADO objects are NULL.
example m_connectionPtr is NULL.
What can the problem be?
thanks guys
keepac
|