当我尝试连接我的C sharp项目以访问2010时,它会给出错误“找不到可安装的ISAM”。 [英] When I try to connect my C sharp project to access 2010 it give error "could not find installable ISAM"

查看:69
本文介绍了当我尝试连接我的C sharp项目以访问2010时,它会给出错误“找不到可安装的ISAM”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



这是App.config文件的代码。


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>





Form1.cs文件的代码





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();
       }
}





我尝试了什么:



我尝试将平台目标更改为x86,x64,任何平台都无效。



What I have tried:

I tried changing platform target to x86, x64, any platform nothing works.

推荐答案

几个问题在这里:检查您的ACE驱动程序 - 如果您尝试使用Office 2010或更高版本的DB,则需要ACE OLEDB V14,而不是V12。

其次,连接字符串中的DataSource应为Data来源,你的字符串中的反斜杠应该是单一的,而不是双倍的。只有当'\'是字符串的转义字符时才需要双反斜杠,例如在C#中 - 而不是在配置文件中。



你应该能够创建一个使用UDL文件工作连接字符串:创建简单SQL连接字符串 [ ^ ] - 我知道它适用于SQL Server,但是没有尝试通过ACE为MDB文件(我没有在这台机器上安装ACE)。
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).


我只是从C复制我的访问数据库:开车到D:驱动器,它的工作原理。我在C:drive中没有管理员权限。
I just copy my access database from C: drive to D: drive and it works. I don't have admin right in C: drive.


这篇关于当我尝试连接我的C sharp项目以访问2010时,它会给出错误“找不到可安装的ISAM”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆