Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When i try to connect my c sharp project to access 2010 it give error "Could not find installable ISAM" and i am using visual studio 2010. but when i use visual studio wizard for connection to database it works

Here is the code of App.config file.
<pre><configuration>
  <appSettings>   
    <add key="connection" value="Provider=Microsoft.ACE.OLEDB.12.0; DataSource=C:\\Users\\Varun\\Documents\\InventoryManagement.accdb"  /> 
  </appSettings>
</configuration>


code of Form1.cs file

using (OleDbConnection con = new OleDbConnection(ConfigurationManager.AppSettings["connection"]))
{
       con.Open();
       OleDbCommand cmd = new OleDbCommand("SELECT * FROM Logg",con);
       OleDbDataReader dr = cmd.ExecuteReader();
       while (dr.Read())
       {
             txtUserName.Text = dr["User_name"].ToString();
       }
}


What I have tried:

I tried changing platform target to x86, x64, any platform nothing works.
Posted
Updated 6-Aug-17 6:29am
v2
Comments
Michael_Davies 6-Aug-17 12:09pm    
Is the Data; valid? and should'nt it be DATA SOURCE not DATASOURCE

Try;

<add key="connection" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Varun\\Documents\\InventoryManagement.accdb" />

https://www.connectionstrings.com/access/
varuncodee 6-Aug-17 12:17pm    
Still not working.
varuncodee 6-Aug-17 12:18pm    
i tried visual studio wizard for connection and it works. But manually by code it's not working.

Couple of problems here: check your ACE driver - if you are trying to use an office 2010 or higher DB, you need ACE OLEDB V14, not V12.
Second, "DataSource" in your connection string should be "Data Source", and the backslashes in your string should be single, not double. Double backslash is only needed when '\' is an escape character for your string such as in C# - not in config files.

You should be able to create a "working" connection string using a UDL file: Simple SQL Connection String Creation[^] - I know it works for SQL Server, but haven;t tried it for MDB files via ACE (and I don't have ACE installed on this machine).
 
Share this answer
 
I just copy my access database from C: drive to D: drive and it works. I don't have admin right in C: drive.
 
Share this answer
 
Comments
Dave Kreskowiak 6-Aug-17 12:53pm    
Yep. In order to open an Access database in your application, the user running your code MUST have write permissions to the folder the database file is in.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900