本文介绍了我得到这样的错误'无法初始化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

推荐答案


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

09-11 18:02