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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with DLL and ADO.

Status
Not open for further replies.

WilliamGS

Programmer
Jan 21, 2004
54
PE
Hi all. I have a Regular DLL that writes and reads in a SQL Server Database using ADO; also, I have a member variable in the application class for the connection:

class CDatabaseMgrApp : public CWinApp
{
//
//...
public:
_ConnectionPtr m_pConnection;
//
//
}

BOOL CDatabaseMgrApp::InitInstance()
{
::CoInitialize(NULL);
m_pConnection.CreateInstance(__uuidof(Connection));

return CWinApp::InitInstance();
}

The DLL and the client programms work fine, the problem shows up when I close de app (EXE), it shows the message:

orgAdmin.exe - App error
The instrucción "0x793dc247" refers to memory in "0x0000048". The memory cannot "written".

In DEBUG mode, this happens in:
int CDatabaseMgrApp::ExitInstance()
{
bool bIsOpen = false;
if (m_pConnection)
bIsOpen = m_pConnection->GetState() != adStateClosed;

if (bIsOpen)
m_pConnection->Close(); //HERE IS THE PROBLEM.

m_pConnection.Release();

::CoUninitialize();
return CWinApp::ExitInstance();
}

'm_pConnection->Close()' is defined in msado15.dli:
inline HRESULT Connection15::Close ( ) {
HRESULT _hr = raw_Close(); //HERE IS THE PROBLEM.
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr;
}

'raw_Close()' causes the problem and it shows the message:
Unhandled exception in orgAdmin.exe (KERNEL32.DLL) 0xC00000005:Access Violation.

I am using VC6.00.
How can I solve this?. Is this a COM problem?
Thanks in advance.

William GS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top