I recently updated my database from .mdb (MS Access 2003) to .accdb (MS Access 2010).
With this update I also updated my provider from: Microsoft.Jet.OLEDB.4.0 to Microsoft.ACE.OLEDB.12.0
The connection works ok when I use a .accdb file without a password, but once I choose to
Encrypt with Password
I receive the following error when I try to open a connection.
Cannot open database ”. It may not be a database that your
application recognizes, or the file may be corrupt.
Used connection string:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\App\\Main\\bin\\Debug\\db.xxx;
Jet OLEDB:Database Password=MyPass;
Note: I use a custom extension for my .accdb file, this was used for .mdb files without problems and I assume this should not be a problem (tested).
I don’t see a problem with your connection string. Still I would try it from VBA to see whether that effort sheds any light on the problem.
This one worked from Access 2007 whether I named the db file with “accdb” or “xxx” file extension. The single quotes are not required around my password; the code succeeded whether or not I included the single quotes.
Edit: Apparently Access 2010 provides a stronger encryption method than earlier Access versions. With
db.xxxopen in Access 2010, check which ACE version is used as theProvider.If it replies something like
Microsoft.ACE.OLEDB.14.0, use that in your c# connection string.