Click to See Complete Forum and Search --> : The ADO Open() call.


Marqy
May 13th, 1999, 11:37 AM
I'm developing a database app using ADO. Everything is fine, however I want to implement a retry system which is used when the Open() call fails due to the database already being opened with the shareExclusive flag set. Open() throws a _com_error, but I can't find any indication of the reason for the exception (the HRESULT of this structure is E_FAIL, which is defined as an unspecified error). Does anyone know how to detect that this call has failed due to file locking?

Cheers

MJA

Alex Black
May 13th, 1999, 12:13 PM
Have you tried e.Error()? (_com_error &e) or
e.WCodeToHRESULT( e.WCode() )?

I use this to find out a description of the error:


TCHAR szSource[255];
TCHAR szDescription[255];

_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());

WideCharToMultiByte( CP_ACP, 0, bstrSource, 255, szSource, 255, 0, 0 );
WideCharToMultiByte( CP_ACP, 0, bstrDescription, 255, szDescription, 255, 0, 0 );