Windows 10 laptop x64 bit
I have Microsoft Access 2010
Drivers installed:
-Microsoft Office Access database engine 2007 (I think 32 bit)
-Microsoft Access database engine 2010 (I think 64 bit)
I recently inherited a C# project (I think .net 4.0) as a junior but I'm having trouble setting up the code properly and from what I've read it is due to the project using a (password protected) Microsoft Access Database. Initially it was handled by one main developer before being handed to me.
Installing the 2007 Microsoft driver helped with "register issues", but I found that the program could not access the database.
Running the code I get an error below.
System.Data.OleDb.OleDbException: Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.
I found that if I open Microsoft Access 2010, create an empty database, import everything from the original database, and then save without a password, then it appears to run fine. But when a password is involved, it stops working
My App.Config file:
<add key ="exampletest"
value ="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\test\testDB.accdb;" />
In my accesshelper file:
Public static readonly string ConnectionString =
ConfigurationManager.AppSettings["exampletest"].ToString() +
"Jet OLEDB:Database Password=Abc1234;";
...
Using (OleDbConnection conn = new OleDbCommection(connectionString))
{
...
If (con.State !=ConnectionState.Open)
conn.Open();
...
}
The code works fine with the original developer, but I can't seem to reproduce the same success without workarounds like removing the password (the password on the code (Abc1234) is correct. I know because if I open the db in Microsoft Access 2010; I have to type the password)