【问题标题】:Import Excel Sheet into SQL Server Getting Error "The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”"将 Excel 表导入 SQL Server 出现错误“链接服务器“(null)”的 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0””
【发布时间】:2016-09-15 09:19:34
【问题描述】:

当我执行此代码 (Excel Sheet to Sql Server) 时出现此错误。

无法为链接服务器“(null)”初始化 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”的数据源对象。 链接服务器“(null)”的 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”返回消息“未指定错误”。

我完成了以下所有事情,

  • sp_configure '显示高级选项',1
  • 重新配置
  • sp_configure '即席分布式查询',1
  • 重新配置

同时安装 2010 Office System 驱动程序:数据连接组件

同样的问题。

【问题讨论】:

标签: c# wpf excel sql-server-2008 excel-2010


【解决方案1】:

由于访问驱动程序和 SQL 服务器之间的不兼容,我遇到了同样的问题。我什至无法更改系统的权限。 以下是对我有用的解决方案:

前置条件:

  • 安装的 Office 产品是 32 位版本。
  • 操作系统是 64 位的。
  • 安装的 SQL Server 是 64 位版本。

问题:

  • 无法执行以下查询:

选择 * 从开放式( '微软.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;数据库=C:\temp\Book.xlsx', '从 [Sheet1$] 中选择 *')

  • 将显示以下错误:
   OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Could not find installable ISAM.".
    Msg 7303, Level 16, State 1, Line 1
    Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
  • 这是因为 64 位 MS Access 驱动程序 (Microsoft.ACE.OLEDB.xx.x) 无法读取 32 位 Excel 文件。

解决方案:

  1. 在命令提示符下以被动模式安装 32 位 MS Access 驱动器,如下所示:

access_drive_path>access_dirve_name.exe /passive

E.g.        C:\Users\user_name\Downloads>AccessDatabaseEngine.exe /passive
  1. 安装 32 位 SQL Server(EXPRESS 版本,因为它是免费的)。

  2. 通过执行以下查询启用 Ad Hoc 分布式查询和动态参数等:

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

USE [master] 
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
  1. 现在尝试在 SQL 查询中读取 Excel 文件 :)

还有一件事....确保您尝试读取的文件没有打开。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多