简体   繁体   English

Microsoft.ACE.OLEDB.12.0无法执行查询

[英]Microsoft.ACE.OLEDB.12.0 Cannot execute the query

I have this sql code. 我有这个sql代码。 It updates a specific cell in an excel file. 它更新excel文件中的特定单元格。

SET @cmd = 'UPDATE OPENROWSET(''Microsoft.ACE.OLEDB.12.0'',''Excel 12.0;Database=C:/sompath/file.xls;HDR=NO;IMEX=0;'',''SELECT F1,F2,F3,F4,F5,F6,F7,F8,F9 FROM [Sheet1$]'')
            set [F1] = ''Hello World''
            where [F1] = ''<field1>'''
EXEC(@cmd)

This piece of code executes successfully in 32bit but fails in 64bit server (MSSQL Server 2012). 这段代码在32位成功执行,但在64位服务器(MSSQL Server 2012)中失败。 I get this error in 64bit: 我在64位中收到此错误:

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "No value given for one or more required parameters.".
Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "SELECT F1,F2,F3,F4,F5,F6,F7,F8,F9 FROM [Sheet1$]" against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

The file.xls is an excel file created in a 32bit pc. file.xls是一个用32位pc创建的excel文件。

Can someone help me with this issue. 有人可以帮我解决这个问题。 I've been searching around the net but really did not get the solution or even some guide to resolving it. 我一直在网上搜索,但实际上没有得到解决方案,甚至没有解决它的指南。 If this question has already been posted and answered, just kindly post the exact link please. 如果这个问题已经发布并得到解答,请发布确切的链接。

By the way, I have already installed the ACE provider and all those settings needed. 顺便说一下,我已经安装了ACE提供程序以及所需的所有设置。 In fact, this code works fine but not with the UPDATE statment: 实际上,此代码工作正常,但不是UPDATE语句:

DECLARE @cmd VARCHAR(1000)
set @cmd = 'SELECT * FROM
            OPENROWSET(''Microsoft.Ace.OLEDB.12.0'',
            ''Excel 12.0;Database=C:/sompath/file.xls;HDR=NO;IMEX=0'',[Sheet1$])'

EXEC(@cmd)

Thanks! 谢谢!

The excel file must be created/resaved from a 64bit MS Office. 必须从64位MS Office创建/重新保存excel文件。 That's all! 就这样!

暂无
暂无

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

相关问题 Microsoft.ACE.OLEDB.12.0错误 - Microsoft.ACE.OLEDB.12.0 Error 无法为链接服务器初始化OLE DB提供程序“ Microsoft.ACE.OLEDB.12.0”的数据源对象 - Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server 无法在64位SQL Server上加载“Microsoft.ACE.OLEDB.12.0” - “Microsoft.ACE.OLEDB.12.0” cannot be loaded in-process on a 64-bit SQL Server 无法在 64 位 SQL Server 上加载 32 位 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0” - The 32-bit OLE DB provider "Microsoft.ACE.OLEDB.12.0" cannot be loaded in-process on a 64-bit SQL Server 链接服务器“(null)”的 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0” - The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" 如何添加预防措施以绕过未注册的 Microsoft.ACE.OLEDB.12.0? - How do I add precautions to get around Microsoft.ACE.OLEDB.12.0 not registered? 通过 OPENROWSET &#39;Microsoft.ACE.OLEDB.12.0&#39; 导出时格式化 Excel 中的单元格 - Formatting the cells in Excel when Export through OPENROWSET 'Microsoft.ACE.OLEDB.12.0' 使用Microsoft.ACE.OLEDB.12.0从网络共享中查询dbf文件时出错 - Error querying dbf file from network share using Microsoft.ACE.OLEDB.12.0 从 excel 导入到 sql server:&#39;Microsoft.ACE.OLEDB.12.0&#39; 提供程序错误 - import from excel to sql server: The 'Microsoft.ACE.OLEDB.12.0' provider error 链接服务器“(null)”的 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”返回消息“JOIN 操作中的语法错误”。 - OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)” returned message “Syntax error in JOIN operation.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM