[英]Cannot initialize the data source object of OLE DB provider Microsoft.ACE.OLEDB.12.0 for linked server (null)
DECLARE @PATH NVARCHAR(1000) = N'\\MY-SERVER\C$\Folder\\'
DECLARE @TABLE NVARCHAR(50) = SUBSTRING(@FILENAME,0,CHARINDEX('.',@FILENAME))
DECLARE @SQL NVARCHAR(4000) =
N'IF OBJECT_ID(''dbo.' + @TABLE + ''' , ''U'') IS NOT NULL
DROP TABLE dbo.[' + @TABLE + ']
SELECT * INTO [' + @TABLE + ']
FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0''
,''Text; Database='+@PATH+';''
,''SELECT * FROM [' + @FILENAME + ']'')'
EXEC(@SQL)
Today I have come across an issue with Microsoft.ACE.OLEDB.12.0 driver in SSIS 2012. The script above sits in a stored procedure which dynamically loads the.csv's into the database based on the current file which is supplied by the SSIS loop in which stored procedure sits.今天我在 SSIS 2012 中遇到了 Microsoft.ACE.OLEDB.12.0 驱动程序的问题。上面的脚本位于一个存储过程中,该过程根据 SSIS 循环提供的当前文件将 .csv 动态加载到数据库中存储过程位于哪个位置。 There are files in the directory.
目录中有文件。
The stored procedure runs correctly when run directly in SQL Server Management Studio.存储过程在 SQL Server Management Studio 中直接运行时正确运行。
This has been working fine up until today.直到今天,这一直运行良好。 Today I am getting the following error:
今天我收到以下错误:
Executing the query "EXEC [dbo].[CreateAndImportCSVs]?"
执行查询“EXEC [dbo].[CreateAndImportCSVs]?” failed with the following error: "Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".".
失败并出现以下错误:“无法为链接服务器“(null)”初始化 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”的数据源 object。”。 Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
可能的失败原因:查询有问题,“ResultSet”属性设置不正确,参数设置不正确,或者连接建立不正确。
Any help on this issue would be great!在这个问题上的任何帮助都会很棒!
Edit编辑
So looking into what's changed I hear alarm bells when I look at the windows updates installed on the server yesterday: The following two were installed:因此,查看发生了什么变化,当我查看昨天安装在服务器上的 windows 更新时,我听到了警钟:安装了以下两个:
Microsoft Office Access Runtime and Data Connectivity 2007 (SP3) http://support.microsoft.com/kb/2526310 Microsoft Office Access 运行时和数据连接 2007 (SP3) http://support.microsoft.com/kb/2526310
Update for the 2007 Microsoft Office System (KB967642) http://www.microsoft.com/downloads/details.aspx?FamilyId=E93AB1BE-ADE6-4FF8-8637-DBD3EBE3C5C5&displaylang=en 2007 Microsoft Office System 更新 (KB967642) http://www.microsoft.com/downloads/details.aspx?FamilyId=E93AB1BE-ADE6-4FF8-8637-DBD3EBE3C5C5&displaylang=en
Many things to Try:很多事情要尝试:
EXCEL
process is not running in backgroundEXCEL
进程没有在后台运行Made sure 'ad hoc distributed queries' was enabled (1)确保“即席分布式查询”已启用 (1)
USE [master] GO EXEC sp_configure 'Show Advanced Options', 1 RECONFIGURE GO EXEC sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE GO EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 GO EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 GO
Read more at How to solve Microsoft.ACE.OLEDB.12.0 error "Unspecified error"在如何解决 Microsoft.ACE.OLEDB.12.0 错误“未指定错误”中阅读更多信息
Also i found an interesting suggested solution in the following link, take a look:我还在以下链接中找到了一个有趣的建议解决方案,看看:
This problem resolved itself.这个问题自己解决了。 There were further updates installed, one of these must have fixed the issue introduced by the previous updates:
安装了进一步的更新,其中之一必须修复了先前更新引入的问题:
Update for Microsoft Office 2010 (KB4011188) 64-Bit Edition https://support.microsoft.com/kb/4011188 Microsoft Office 2010 (KB4011188) 64 位版更新https://support.microsoft.com/kb/4011188
Update for Microsoft Office 2010 (KB2553347) 64-Bit Edition http://support.microsoft.com/kb/2553347 Microsoft Office 2010 (KB2553347) 64 位版更新http://support.microsoft.com/kb/2553347
Security Update for Microsoft Office 2010 (KB2553338) 64-Bit Edition https://support.microsoft.com/kb/2553338 Microsoft Office 2010 安全更新 (KB2553338) 64 位版https://support.microsoft.com/kb/2553338
Thanks for all the help with this!感谢您对此的所有帮助!
The final piece that solved this for me was moving the spreadsheet to a windows directory that SQL Server was able to access.为我解决这个问题的最后一块是将电子表格移动到 SQL Server 能够访问的 Windows 目录。 I moved my spreadsheet to a new subdirectory, within the directly where my sql database was located, and the problem was resolved.
我将我的电子表格移动到一个新的子目录,在我的 sql 数据库所在的直接位置,问题得到解决。
SQL Server is not able to access the Access provider, if the installation of office was Click to Run installation. SQL 如果 office 的安装是单击以运行安装,则服务器无法访问访问提供程序。
The issue can be resolved by any of the following approaches.该问题可以通过以下任何一种方法解决。
OLEDB driver issues resolution OLEDB驱动问题解决
Resolution
解析度
Beginning with Microsoft 365 Apps for Enterprise Version 2009, work has been completed to break ACE out of the C2R virtualization bubble so that applications outside of Office are able to locate the ODBC, OLEDB and DAO interfaces provided by the Access Database Engine within the C2R installation.
从 Microsoft 365 Apps for Enterprise Version 2009 开始,ACE 已完成从 C2R 虚拟化泡沫中脱离出来的工作,以便 Office 外部的应用程序能够在 C2R 安装中找到 Access 数据库引擎提供的 ODBC、OLEDB 和 DAO 接口.
Use the following table to understand if additional components are necessary to access these intefaces within your environment:
使用下表了解是否需要额外的组件来访问您环境中的这些接口:
Probably not a solution, but you should execute SQL with:可能不是解决方案,但您应该使用以下命令执行 SQL:
sp_executesql @SQL
It protects from injection and wotnot.它防止注射和wotnot。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.