繁体   English   中英

将Excel工作表导入SQL Server获取错误“OLE DB提供程序”Microsoft.ACE.OLEDB.12.0“用于链接服务器”(null)“”

[英]Import Excel Sheet into SQL Server Getting Error “The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)””

当我实现此代码( Excel Sheet到Sql Server )时出现此错误。

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

我完成了以下所有事情,

  • sp_configure'show advanced options',1
  • 重新配置
  • sp_configure'Ad Hoc Distributed Queries',1
  • 重新配置

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

然后也是同样的问题。

由于访问潜水员和SQL服务器之间不兼容,我遇到了同样的问题。 我甚至无法更改系统的权限。 以下是适合我的解决方案:

前提:

  • 安装的Office产品是32位版本。
  • O / S是64位。
  • 安装的SQL Server是64位版本。

问题:

  • 无法执行以下查询:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0; HDR = YES; Database = C:\\ temp \\ Book.xlsx','select * from [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 Distributed查询和动态参数等:

 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文件:)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM