troubleshooting Question

C++ MFC CDatabase Unhandled Exception, Access violation when calling Open or OpenEx MS Access

Avatar of bowser17
bowser17 asked on
Microsoft AccessSystem ProgrammingEditors IDEs
15 Comments1 Solution2403 ViewsLast Modified:
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);

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.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros