0

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)

LarsTech
  • 80,625
  • 14
  • 153
  • 225
CaptainObv
  • 360
  • 1
  • 4
  • 15

1 Answers1

0

Found the resolution The issue from what I've researched seems to be compatibility/conflict issues between 32bit/64bit Microsoft database drivers

(For reference, I have: Microsoft Access 2010 64 bit Microsoft Office Access Database engine 2007 (a 32bit driver) Microsoft Access database engine 2010 (a 64bit driver) )

Driver-side, not sure I need both. But the 2007 driver was a MUST for me

Now for the resolution:

In visual studio I just need to right click on the project and in the build section I just select "Any CPU" as the platform target (not the same as selecting Any CPU for debug/release

CaptainObv
  • 360
  • 1
  • 4
  • 15