Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

CDatabase::open crash if the access database file not present in the location speciifed.

$
0
0

Hi,

I am working on an application in which if database file does not exist in the proper location i would like to exit from the application.

But if the file not present in the proper location , it throwing up the erro message.

Please find the below code snippet.

CDatabase *m_AccessDb = new CDatabase;
CString strConString = L"ODBC;DSN=MS Access Database;DBQ=";
strConString += "C:\\Database\\AccessDb.mdb";
strConString += ";DefaultDir=\\database;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;";
int iret = m_AccessDb->Open(strConString, FALSE, FALSE, _T("ODBC;"), FALSE);
if(!iret){
MessageBox(L"Database not opened");
exit(0);
}

If the AccessDb.mdb file not present in the location.it throws up a message box which contains ok and cancel buttons.

when cancel button has been clicked it will be enter into the if loop and displays the message box like Database not opened

after that exit(0) gets called. In this case application throws up the error message like

"

First-chance exception at 0x7707380B (ntdll.dll) in MFCApplication3.exe: 0xC0000420: Assertion Failure (parameters: 0x004F9590).

If there is a handler for this exception, the program may be safely continued.

"

Could you pls help me out.

Thanks & Regards,

Prasanthi



Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>