使用Microsoft.ACE.OLEDB.12.0将数据从Excel导入到SQL Server数据库

我正在开发一个应用程序,我需要从Excel导入数据到MS SQL Server数据库。 我已经在MS SQL Server机器上和我的机器上安装了Microsoft Access数据库引擎2010 Redistributable

像这样configurationMS SQL Server:

USE [master] GO sp_configure 'show advanced options', 1 GO RECONFIGURE WITH OverRide GO sp_configure 'Ad Hoc Distributed Queries', 1 GO RECONFIGURE WITH OverRide GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1 GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1 GO 

在我的应用程序中,我使用:

 SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=PathToMyExcelDoc', [Devices$]) 

当应用程序和SQL Server在同一台机器上时,它工作正常,但是当我在我的机器上运行应用程序并尝试将数据从Excel导入到远程SQL Server时,出现以下错误:

 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". 

我一直面临同样的问题,我解决了这个问题,首先将excel保存到服务器,然后在OPENROWSET中传递该path。