[ODBC]读Excel时报错:外部数据库驱动程序(1)中的意外错误解决方案

来源:互联网 发布:苹果音乐软件 itunes 编辑:程序博客网 时间:2024/05/21 09:16

在MFC下使用ODBC读取Excel数据库,之前用着还好好的,突然就用不了了,几经查找发现是Windows安全更新的补丁搞的鬼。

出现错误:
ODBC ERROR


解决方案:
1. 在控制面板——卸载——已安装更新,找到并删除以下安全更新:

System Patch Num Uninstall Command Windows 7 、Windows Server 2008 R2 KB4041681 wusa /uninstall /kb:4041681 Windows 8 、Windows Server 2012 KB4041693 wusa /uninstall /kb:4041693 Windows 10 V1607 、 Windows Server 2016 KB4041691 wusa /uninstall /kb:4041691 Windows 10 V1703 KB4041676 wusa /uninstall /kb:4041676

或者以管理员权限运行cmd,并执行wusa /uninstall命令卸载,然后重启即可。
这里写图片描述

2. 修改注册表(非专业人员慎用)
- 找到老版本的(4.0.9801.0) msexcl40.dll
- 复制到另一个目录(比如:C:\ProgramData\JET_Fix\msexcl40.dll)
- 将HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel\win32的值修改成C:\ProgramData\JET_Fix\msexcl40.dll
JetFix

3. 安装新的数据库引擎AccessDatabaseEngine
安装Microsoft Access Database Engine 2010 Redistributable并使用新的provider连接

将连接串
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.xls;Extended Properties=”Excel 8.0”;
改为
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\test.xls;Extended Properties=”Excel 8.0”;


参考:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/55b1d633-b715-491e-917e-b7cb01ae0523/error-in-windows-update-kb4041681-unexpected-error-from-external-database-driver-1?forum=sqldataaccess

阅读全文
0 0
原创粉丝点击