user13770736
user13770736

Reputation:

System.Data.OleDb.OleDbException: 'Could not find installable ISAM.' - MS Access (.accdb) and C# (.Net Framework)

There were few similar questions here, but i couldn't locate any with acceptable answer. or that it would actually work one.

I have create a local storage as .accdb file and tried to connect witch c# to it.

In summary those are the parts needed:

public static string accessConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\MS_Access_Test_DB.accdb";

OleDbConnection connection = new OleDbConnection(accessConnectionString);
connection.Open();

It always crashes, with an error from description. I had tried to use apostrophes, quotes etc for C:\MS_Access_Test_DB.accdb

I had also tried JET.4.0 with same error & adding Persist Security Info=True; into the mix.

Upvotes: 2

Views: 2752

Answers (2)

Ahmad Hassan
Ahmad Hassan

Reputation: 23

The Error is in your Connection String. You must add Space between the words Data and Source, unless it won't work

Below here is the correct version:

public static string accessConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MS_Access_Test_DB.accdb";

OleDbConnection connection = new OleDbConnection(accessConnectionString);
connection.Open();

Upvotes: 0

user13770736
user13770736

Reputation:

Ok,

The issue as pointed out by Steeeve & Panagiotis Kanavos using is access driver 32bit when i use 64bit architecture, and this will not work. Especially in office/corporation that already has a lot of build in add-ins for office 32 bit. There is also workaround, to install both drivers, but it would require each user to have it, therefore it wasn't solution in my case.

Id much prefer using SQLite, but the tables have to be connected to PowerBI i now that SQLite have to use external drivers to update datasets, therefore for now, this solution was also out.

Considering I cannot force each user to change drivers etc. I tried and saved the access file as .mdb (2002-2003).

So it's either: intalling 64bit driver (proposed initialy) or a workaround (with .mdb):

public static string accessConnectionString = @"Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\MS_Access_Test_DB.mdb";
            OleDbConnection connection = new OleDbConnection(accessConnectionString);
            connection.Open();

Or:

public static string accessConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MS_Access_Test_DB.mdb";
            OleDbConnection connection = new OleDbConnection(accessConnectionString);
            connection.Open();

Important note, there is lot of .accdb functionalities that cannot be used in .mdb, so if you have to use access, than be carefull. If you can, consider SQLite/SQL SE proposed in comment's under my question.

EDIT: I had also messed up the first time... Instead of DataSource I should have had Data Source so it seems to work, despite using Driver 32bit against 64bit app.

Upvotes: 1

Related Questions