_RecordsetPtr Detach / Debug Exception
-
Hi! I'm new to posting here, but I wanted to start out with an annoying feature that was bugging me. I get to do a lot of the weird programming assignments..... I've got a ATL/COM Service that has one Simple ATL Apartment object. It takes a flat file record and converts it into a one row recordset with appropriate columns. It has a method to pass a detached recordset back and forth, such as this: [id(2), helpstring("method ReadRecord")] HRESULT ReadRecord([in, out] VARIANT *iRetVal, [out, retval] IUnknown **ppRecordset); STDMETHODIMP CGenericObj::ReadRecord(VARIANT *iRetVal, IUnknown **ppRecordset) It works perfectly fine, except when you get into the debugger, and only once you get out of the raw_ReadRecord. First-chance exception in Generic.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception. But, everything works fine, even in release mode. When I don't detach the recordset, the message does not surface. When the object is passed back in through: STDMETHODIMP CGenericObj::WriteRecord(IUnknown *pRecordset, VARIANT *iRetVal) It does the same thing. The code to generate it: _RecordsetPtr m_pRs; m_pRs.CreateInstance(__uuidof(Recordset)); (read field loop) m_pRs->Fields->Append(_T((LPCSTR)pField.sExternalName), lEnum, lFieldSize, adFldIsNullable); (read field loop end) _variant_t vNull(DISP_E_PARAMNOTFOUND,VT_ERROR); m_pRs->Open(vNull,vNull,adOpenForwardOnly, adLockOptimistic, adCmdUnknown); m_pRs->AddNew(); (read file field loop) m_pRs->Update(); *ppRs = m_pRs.Detach(); Just curious what you coders think....
-
Hi! I'm new to posting here, but I wanted to start out with an annoying feature that was bugging me. I get to do a lot of the weird programming assignments..... I've got a ATL/COM Service that has one Simple ATL Apartment object. It takes a flat file record and converts it into a one row recordset with appropriate columns. It has a method to pass a detached recordset back and forth, such as this: [id(2), helpstring("method ReadRecord")] HRESULT ReadRecord([in, out] VARIANT *iRetVal, [out, retval] IUnknown **ppRecordset); STDMETHODIMP CGenericObj::ReadRecord(VARIANT *iRetVal, IUnknown **ppRecordset) It works perfectly fine, except when you get into the debugger, and only once you get out of the raw_ReadRecord. First-chance exception in Generic.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception. But, everything works fine, even in release mode. When I don't detach the recordset, the message does not surface. When the object is passed back in through: STDMETHODIMP CGenericObj::WriteRecord(IUnknown *pRecordset, VARIANT *iRetVal) It does the same thing. The code to generate it: _RecordsetPtr m_pRs; m_pRs.CreateInstance(__uuidof(Recordset)); (read field loop) m_pRs->Fields->Append(_T((LPCSTR)pField.sExternalName), lEnum, lFieldSize, adFldIsNullable); (read field loop end) _variant_t vNull(DISP_E_PARAMNOTFOUND,VT_ERROR); m_pRs->Open(vNull,vNull,adOpenForwardOnly, adLockOptimistic, adCmdUnknown); m_pRs->AddNew(); (read file field loop) m_pRs->Update(); *ppRs = m_pRs.Detach(); Just curious what you coders think....
-
Heh, as it reads in the question itself (First Chance exception....), only unless you turn off automatic handling of that exception, it just does a print to the debug window.... Ah well...perhaps I didn't build the object right...
-
"First chance exception in ... : Microsoft C++ Exception" means a C++ exception is thrown but not catch. Try to wrap up your method call in a try / catch statement, and catch a _com_error exception. Take a look at the error code.