VC6.0 m_pConnection.CreateInstance 问题
m_pConnection.CreateInstance时报 Access Violation,应该是内存泄漏,但后面Open Connectstr没问题程序能正常运行。这是怎么回事?
::CoInitialize(NULL);
HRESULT hr;
_ConnectionPtr m_pConnection;
hr=m_pConnection.CreateInstance(__uuidof(Connection));
if (SUCCEEDED(hr))
{
AfxMessageBox("You are now Connected!",NULL,MB_OK); //Not Executed
}
else if(FAILED(hr))
AfxMessageBox("Not able to connect to DB!",NULL,MB_OK); //Executed
---------
output 中显示如下
First-chance exception in testADOConn.exe (KERNEL32.DLL): 0xC0000005: Access Violation.