Click to See Complete Forum and Search --> : why does CreateInstance("ADODB.Connection") bring out exception?
liuyue
June 23rd, 2005, 05:29 AM
before long, the program can run without error,but today it don't run.
m_pConnection.CreateInstance("ADODB.Connection") return 0, and there is the exception----First-chance exception in GIS.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
i write it in mfc.
how can figure it out ?
matthewp
June 23rd, 2005, 06:02 AM
You say
m_pConnection.CreateInstance("ADODB.Connection")
returns 0 so is m_pConnection a valid instance (m_pConnection != 0x00)?
CreateInstance returns S_OK (0x00000000) to indicate success.
You need to find exactly where the exception is thrown, so step through your code in debug mode until the exception occurs.
Do you initialise COM (CoInitialize(NULL))? This needs to be done for each thread that uses ADO.
Hope this helps
Regards
Matt
liuyue
June 23rd, 2005, 07:00 AM
thank you for your answer! i figure out it
JKuehl
July 27th, 2005, 06:50 AM
Having the exact same Problem here -
BUT the Error canīt be exactly Traced to CreateInstance. Now the error appers later (in Recptr->Open) - WITHOUT changing my source code - anyone got a solution? Could this be still the Problem with my CnnPtr Object?
Edit: Almost forgot - hr always shows correct execution of the commands. (returns 0)
Code follows:
hr = CoInitialize(NULL);
hr = CnnPtr.CreateInstance(__uuidof(Connection));
.
.
.
_bstr_t bstrQuery = L"SELECT * FROM tabelle";
_variant_t vQuery(bstrQuery);
_variant_t vDispatch((IDispatch*)CnnPtr);
CnnPtr->AddRef();
hr = RecPtr->Open(vQuery,vDispatch,adOpenDynamic, adLockOptimistic, adCmdUnknown);
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.