When trying to open a MS Access database .mdb using C++ MFC CDatabase object, i try using Open or OpenEx, and i get:
Unhandled exception at 0x00000000 in MPUtilD.exe: 0xC0000005: Access violation reading location 0x00000000.
The mysterious part is this code was working, and now it doesn't. I thought it may be some database change i made, maybe corrupting something, but i tried repair and compact. I even tried an older version of the database from a backup when i know for sure it was working. Nothing! I've changed the path, the name of the database, tried slight variations of the connection string... nothing works. Im super frustrated.
Here is how i build the connection string:
CDatabase db;
CString cnStr;
cnStr.Format("ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};DSN='';DBQ=%s",sFile);
db.OpenEx(cnStr);
sFile is the path to the database, and is passed in. I check the value of cnStr prior to stepping through OpenEx, and verify the string is good.
Also try a decompile, see if that helps http://www.granite.ab.ca/access/decompile.htm
Compact/Repair doesnt always repair corrupted databases, thats if u have one
so try this
create a brand new database then create a new table there. Does accessing that work?
If so then try importing some tables from the old db into this new db. Does accessing them work?
Another recovery method is to import objects from old db to new db