我得到这样的错误'无法初始化OLE DB提供程序的数据源对象“Microsoft.ACE.OLEDB.12.0”对于链接服务器' [英] I got error like this 'Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server '

查看:209
本文介绍了我得到这样的错误'无法初始化OLE DB提供程序的数据源对象“Microsoft.ACE.OLEDB.12.0”对于链接服务器'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I got error like this 'Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ClientAc901".
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ClientAc901" returned message "The Microsoft Office Access database engine cannot open or write to the file '\\Pc09\data3\accountdata.mdb'. It is already opened exclusively by another user, or you need permission to view and write its data.".' while importing msaccess data to sql.





这里msaccess数据库连接状态关闭,但我得到同样的错误。



我写了这段代码来将表从msaccess复制到sql





Here the msaccess database connection state is closed still i am getting same error.

I have written this code to copy tables from msaccess to sql

void copytable()
      {
          try
          {
              cmd = new SqlCommand("SP_Create");
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.Parameters.AddWithValue("@servername", acc);
              cmd.Parameters.AddWithValue("@datasr", path);
              cmd.Parameters.AddWithValue("@table", sourcetable);
              cmd.Parameters.AddWithValue("@table1", desttable);
              cmd.Parameters.AddWithValue("@db", db);
              cmd.CommandTimeout = 180;
              cmd.Connection = cn1;
              connection.Close();
              string state = connection.State.ToString();
              if (cn1.State != ConnectionState.Open) { cn1.Open(); }
              cmd.ExecuteNonQuery();
              cn1.Close();
          }
          catch (Exception exc)
          {
              connection.Close();
          }
      }





名称连接是msaccess连接,即oledb和cn是sql连接



The name connection is msaccess connection i.e oledb and cn is sql connection

推荐答案

该消息与代码无关......这是关于您可能没有的访问和许可...

它清楚地说明了什么你必须检查...

1.文件可能从其他地方打开

2.你(SQL用户)可能无法访问它



要检查您的设置,首先去SSMS并检查链接服务器......
The message has nothing to do with code...It is about access and permission you may not have here...
It states clearly what you have to check...
1. The file may be opened from elsewhere
2. You (the SQL user) may have no access to it

To check your setup, first go SSMS and check there the linked server...


这篇关于我得到这样的错误'无法初始化OLE DB提供程序的数据源对象“Microsoft.ACE.OLEDB.12.0”对于链接服务器'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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