0

I'm using ACE OLEDB to run a query on an MS Access mdb file. This works on x86 machines but fails on x64.

C# code (built with target platform x86):

string conn = "Provider=Microsoft.ACE.OLEDB.12.0;data source=" + @"C:\abc\db\file.mdb";
OleDbConnection _connOle = new OleDbConnection(conn);
_connOle.Open();

OleDbCommand cmd = new OleDbCommand();
cmd.Connection = _connOle;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from myTable";

cmd.ExecuteReader();

The error I get is "Your network access was interrupted. To continue, close the database, and then open it again."

UPDATE: This only happens when my mdb file has linked tables. If the tables are imported this does not happen! Let me add that, I have made sure that the user has full access to the folder \AppData\Local\Temp in case the ACE.OLEDB engine needs to access it for temporarily storing linked tables.

Any ideas on how to fix this? Thanks!

Mossi
  • 997
  • 5
  • 15
  • 28

1 Answers1

0

Close the existing connection, add this to the end:

conn.close();
devilfish17
  • 337
  • 3
  • 10
  • I had tried closing and opening the Connection before calling cmd.ExecuteReader(). That didn't make a difference. I had also tried just closing the Connection but it complained saying that the Connection needed to be opened first. – Mossi Mar 21 '13 at 20:45
  • Btw I had forgotten to include the _connOle.Open() statement in my original post. I had it in my code but forgot to copy it to my post. – Mossi Mar 21 '13 at 21:00