如何解决“找不到可安装的 ISAM。” OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”错误

发布于 2024-12-26 00:52:09 字数 3168 浏览 6 评论 0原文

我正在尝试使用带有“Microsoft.ACE.OLEDB.12.0”OLE DB 提供程序的 T-SQL OpenRowset() 命令将数据从 Excel 2007 (.xlsx) 文件导入 SQL Server 2008,并且我得到了持久的“找不到可安装的 ISAM”错误。所有硬件都是 32 位的。

[已于 2012 年 1 月 10 日修订,以尝试更清晰地关注异常情况]

以下 T-SQL 语句会产生错误:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES"',
    'SELECT * FROM [Sheet1$]'
)

如果我将 Excel 文件保存为“Excel 97-2003”格式 ( .xls)并使用较旧的 Microsoft.Jet.OLEDB.4.0 提供程序导入数据,它工作得很好。这让我认为这不是安全或其他环境问题。

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
    'Excel 8.0;Database=C:\work\TestData.xls;HDR=YES', 
    'SELECT * FROM [Sheet1$]'
)

但是,当我尝试使用 Microsoft.ACE.OLEDB.12.0 提供程序(应向后兼容 *.xls 格式)的 *.xls 文件时,它再次失败并出现相同的错误:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Data Source=C:\work\TestData.xls;Extended Properties="Excel 8.0;HDR=YES";', 
    'SELECT * FROM [Sheet1$]'
)

此外,有趣的是,当我使用 SSMS 时“导入数据...”向导,工作正常。我将导入数据向导输出保存为 SSIS 包,并查看 SSIS 文件以尝试弄清楚它是如何工作的,它成功地使用了 Microsoft.ACE.OLEDB.12.0 提供程序。这是来自 SSIS 包的连接字符串:

<DTS:Property DTS:Name="ConnectionString">
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES";
</DTS:Property>

我还完成了相关的 SQL Server 配置以允许 OPENROWSET 分布式查询:

sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
GO

如果我还设置了以下 *sp_MSset_oledb_prop* 值(我在某处的帖子中找到)

USE [master] 
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 

...。 ..然后错误更改为“未指定错误”:

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".
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)".

但是,我不确定这是上游还是下游错误。 (现在是否找到了“可安装的 ISAM”,但随后失败了?)

我已经在两台不同的计算机/操作系统(Windows Server 2003、Windows XP SP3)上对多个 Excel 文件进行了尝试。两台机器都是 32 位的。

我还尝试重新安装 Office 2007 和 Office 2010 版本的 AccessDatabaseEngine.exe (http ://www.microsoft.com/download/en/details.aspx?id=23734http://www.microsoft.com/download/en/details.aspx?id=13255 分别),但无济于事。

总结一下:

  • “Microsoft.Jet.OLEDB.4.0”提供程序使用 T-SQL 运行,但“Microsoft.ACE.OLEDB.12.0”则不能。
  • “Microsoft.ACE.OLEDB.12.0”使用“导入数据...”向导工作(据我从保存的 SSIS 作业文件中可以看出)。
  • 将“AllowInProcess”和“DynamicParameters”属性设置为“1”会将错误更改为“未指定错误”。 (这是向前迈出的一步吗?!)

有什么想法吗?

I am trying to import data from Excel 2007 (.xlsx) files into SQL Server 2008 using a T-SQL OpenRowset() command with the "Microsoft.ACE.OLEDB.12.0" OLE DB provider, and I'm getting a persistent "Could not find installable ISAM" error. All hardware is 32-bit.

[Revised 1/10/12 to try to focus more sharply on the anomalies]

The following T-SQL statement produces the error:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES"',
    'SELECT * FROM [Sheet1$]'
)

If I save the Excel file in the "Excel 97-2003" format (.xls) and use the older Microsoft.Jet.OLEDB.4.0 provider to import the data, it works just fine. This makes me think it is not a security or other environmental issue.

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
    'Excel 8.0;Database=C:\work\TestData.xls;HDR=YES', 
    'SELECT * FROM [Sheet1$]'
)

However, when I try the *.xls file with Microsoft.ACE.OLEDB.12.0 provider, which should be backward compatible with the *.xls format, it again fails with the same error:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Data Source=C:\work\TestData.xls;Extended Properties="Excel 8.0;HDR=YES";', 
    'SELECT * FROM [Sheet1$]'
)

Also, interestingly, when I use the SSMS "Import Data..." wizard, it works fine. I saved the Import Data wizard output as an SSIS package and looked in the SSIS file to try to figure out how it works, and it IS successfully using the Microsoft.ACE.OLEDB.12.0 provider. This is the connection string from the SSIS package:

<DTS:Property DTS:Name="ConnectionString">
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES";
</DTS:Property>

I've also done the relevant SQL Server configuration to allow the OPENROWSET distributed query:

sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
GO

If I also set the following *sp_MSset_oledb_prop* values (which I found in a post somewhere)...

USE [master] 
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 

...then the error changes to "Unspecified error":

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".
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)".

However, I am not sure if this an upstream or downstream error. (Is it now finding the "installable ISAM" but failing subsequently?)

I have tried this with multiple Excel files on two different machines/OSes (Windows Server 2003, Windows XP SP3). Both machines are 32-bit.

I've also tried re-installing both the Office 2007 and Office 2010 versions of AccessDatabaseEngine.exe (http://www.microsoft.com/download/en/details.aspx?id=23734 and http://www.microsoft.com/download/en/details.aspx?id=13255, respectively), to no avail.

To summarize:

  • "Microsoft.Jet.OLEDB.4.0" provider works using T-SQL, but "Microsoft.ACE.OLEDB.12.0" does not.
  • "Microsoft.ACE.OLEDB.12.0" works using the "Import Data..." wizard (as far as I can tell from the saved SSIS job file).
  • Setting the "AllowInProcess" and "DynamicParameters" properties to "1" changes the error to "Unspecified error". (Is that a step forward?!)

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

梦亿 2025-01-02 00:52:09

尝试一下,它可能会帮助您:

根据要求设置 pathstrFileType

      string connString = "";
//    string strFileType = Path.GetExtension(UpfileName.FileName).ToLower();
//    string path = UpfileName.PostedFile.FileName;

if (strFileType.Trim() == ".xls")
   {

      connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
   }
   else if(strFileType.Trim() == ".xlsx")
    {
            connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
    }

TRY this it may help you:

set path and strFileType as per requirement

      string connString = "";
//    string strFileType = Path.GetExtension(UpfileName.FileName).ToLower();
//    string path = UpfileName.PostedFile.FileName;

if (strFileType.Trim() == ".xls")
   {

      connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
   }
   else if(strFileType.Trim() == ".xlsx")
    {
            connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
    }
意中人 2025-01-02 00:52:09

最后,一个解决方案!

看看这个:消息 7302,级别 16,状态 1,第 1 行无法为链接服务器“(null)”创建 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”的实例

基本上,您可以到

控制面板>管理工具>组件服务

然后扩展

组件服务>计算机>我的电脑> DCOM配置

查找

MSDA初始化

转到

属性>安全>启动和激活权限

单击

自定义>编辑...

添加您的登录名或“Everyone”(如果您愿意)

勾选新用户/组的所有“允许”框

,然后在两个页面上单击“确定”

现在查看您的 OpenRowSet / OpenDataSource 命令是否有效

感谢 来自 Social.technet.microsoft.com 的 Ramesh Babu Vavilla (vr.babu)对于链接

FINALLY, a solution!

Check this out: Msg 7302, Level 16, State 1, Line 1 Cannot create an instance of OLE DB Provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”

Basically, you go to

Control Panel > Administrative Tools > Component Services

then expand

Component Services > Computers > My Computer > DCOM Config

find

MSDAINITIALIZE

go to

Properties > Security > Launch and Activation Permissions

click on

Customize > Edit...

add your login name or "Everyone" if you prefer

tick ALL the "allow" boxes for the new user / group

and hit OK on both pages

Now see if your OpenRowSet / OpenDataSource command works

Thanks to Ramesh Babu Vavilla (vr.babu) from social.technet.microsoft.com for the link

翻身的咸鱼 2025-01-02 00:52:09

这对我有用

Select *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
                'text;
                 HDR=yes;
                 imex=1;
                 driver={Microsoft text Driver (*.xls, *.xlsx, *.xlsm, *.xlsb,*.csv)}; 
                 extended properties=excel 12.0 xml; 
                 Database=<path>\', 
                'SELECT * from [<filename>#csv]')

This worked for me

Select *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
                'text;
                 HDR=yes;
                 imex=1;
                 driver={Microsoft text Driver (*.xls, *.xlsx, *.xlsm, *.xlsb,*.csv)}; 
                 extended properties=excel 12.0 xml; 
                 Database=<path>\', 
                'SELECT * from [<filename>#csv]')
茶底世界 2025-01-02 00:52:09

试试这个

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                'EXCEL 12.0;DataBase=C:\TEMP\test.xlsx;Extended Properties="EXCEL 12.0 Xml;HDR=YES', [Sheet1$])

Try This

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                'EXCEL 12.0;DataBase=C:\TEMP\test.xlsx;Extended Properties="EXCEL 12.0 Xml;HDR=YES', [Sheet1$])
墨小沫ゞ 2025-01-02 00:52:09

海也面临这种情况我解决了它

解决了

string ConeectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + txtFlp.Text 

    + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"");

                OleDbConnection oconn = new OleDbConnection(ConeectionString);</b>

Hai am also faced this situation i solved It

Solved

string ConeectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + txtFlp.Text 

    + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"");

                OleDbConnection oconn = new OleDbConnection(ConeectionString);</b>
明明#如月 2025-01-02 00:52:09

确保连接字符串的扩展属性部分的引号为我解决了这个问题。我添加了一个额外的属性,并且没有将报价迁移到新属性之后的末尾。

Ensuring quotations around extended properties section of the connection string fixed it for me. I had added an additional property and didn't migrate the quote to the end after my new property.

忆悲凉 2025-01-02 00:52:09

我有同样的问题
我查看了成功运行的SSIS包代码。
我注意到与我们的代码相比,16 和 12(OLEDB 和 Excel 的版本)在那里交换了!
这对我有用:

OPENROWSET('Microsoft.ACE.OLEDB.16.0','Excel 12.0;Database=...

I had the same problem
I looked at SSIS package code which was running successfully.
I noticed that 16 and 12 (Versions of OLEDB and Excel) are exchanged there in comparison to our code!
This worked for me:

OPENROWSET('Microsoft.ACE.OLEDB.16.0','Excel 12.0;Database=...
旧梦荧光笔 2025-01-02 00:52:09

我认为答案隐藏在您发布的 SSIS 包信息中。新的文件格式 xlsx 以 XML 格式而不是旧格式存储数据。再看一下。上面写着...
Extended Properties="Excel 12.0 XML;HDR=YES

不要错过标准内容之后的 XML。(就其价值而言,我还读到您需要“Excel 12.0 宏”才能连接 xslm 文件。

)尝试一下,但希望它有效。

I think the answer is hiding in the SSIS package info you posted. The new file format xlsx, stores the data in XML format instead of the old format. Look at it again. It reads...
Extended Properties="Excel 12.0 XML;HDR=YES

Don't miss that XML after the standard stuff. (For what it's worth, I also read that you need "Excel 12.0 Macro" to connect with an xslm file.)

Give it a try. Weird but hopefully it works.

老子叫无熙 2025-01-02 00:52:09

我已经解决了这个查询:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
    'Excel 12.0;HDR=NO;Database=D:\Filename.xlsx;', 
    [SheetName$])

sql 似乎不喜欢“扩展属性”部分...

i've resolved with this query:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
    'Excel 12.0;HDR=NO;Database=D:\Filename.xlsx;', 
    [SheetName$])

It seems sql doesn't like the "Extended Properties" section...

野生奥特曼 2025-01-02 00:52:09

这对我有用:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
   'Excel 12.0;HDR=NO;Database=C:\temp\file.xlsx;',[sheetname$])

This worked for me:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
   'Excel 12.0;HDR=NO;Database=C:\temp\file.xlsx;',[sheetname$])
ペ泪落弦音 2025-01-02 00:52:09

如果您完成了所有这篇文章并继续出现错误。
尝试分配文件夹 pdf 的权限,以

NT Service\MSSQLSERVER
NT Service\SQLSERVERAGENT

适合我的帐户

If you do all this post and continue with te error.
try to assign permisiton on the folder pdf, to account

NT Service\MSSQLSERVER
NT Service\SQLSERVERAGENT

works for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文