在 Excel 升级后评估 EOF 时 ADO 记录集崩溃 [英] ADO recordset crashes while evaluating EOF after Excel upgrade

查看:80
本文介绍了在 Excel 升级后评估 EOF 时 ADO 记录集崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Excel 工作表,它使用 ODBC 连接连接到 Basis 数据库.当我们在 Windows Server 2008 上运行 Excel 2010 时,它运行良好,但后来我们在 Windows Server 2016 上升级到 Excel 2016,它不再工作了.

I have an Excel sheet that connects to a Basis database using an ODBC connection. It worked fine when we were running Excel 2010 on Windows Server 2008, but then we upgraded to Excel 2016 on Windows Server 2016, and it doesn't work anymore.

下面是一些演示问题的代码:

Here's some code that demonstrates the problem:

Public Sub cnntest()
Dim cnn As ADODB.Connection
Dim sql As String
Dim rs As ADODB.Recordset

Set cnn = New ADODB.Connection
cnn.Open "DSN=redacted;UID=redacted;PWD=redacted;"

sql = "SELECT ITEM FROM IC_ITM_MST WHERE ITEM = '1400-4'"
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseServer
rs.Open sql, cnn

For Each a In rs.Fields
    Debug.Print a.Name
Next a

Debug.Print rs.EOF

rs.Close
cnn.Close
End Sub

当我运行上面的代码时,它会打印字段的名称,所以我知道它正在连接到数据库并执行查询.但是,当它尝试评估 rs.EOF 时,它立即崩溃并抛出一条错误消息,指出Microsoft Excel 已停止工作".当我将鼠标悬停在代码的那部分时,它也会这样做.当我在 Windows Server 2008 上的 Excel 2010 上尝试时,完全相同的代码运行良好.

When I run the above code, it prints the name of the field, so I know that it's connecting to the database and executing the query. However, when it tries to evaluate rs.EOF, it immediately crashes and throws up an error message saying "Microsoft Excel has stopped working." It also does this when I mouse over that part of the code. The exact same code runs fine when I try it on Excel 2010 on Windows Server 2008.

知道为什么它适用于旧版 Excel 而不适用于新版吗?关于如何修复它的任何想法?

Any idea why it works on the old version of Excel but not the new one? Any ideas on how to fix it?

推荐答案

四个月后,我终于找到了答案.我使用 Windows 事件查看器查看崩溃的错误日志,上面写着

Four months later, I finally found the answer. I used the Windows event viewer to look at the error logs for the crashes, which said

"错误的应用程序名称:EXCEL.EXE,版本 16.0.4266.1001,时间邮票:0x55ba1551错误模块名称:BBjODBC.dll,版本 14.1.1.0,时间戳:0x5400df87异常代码:0xc0000005

"Faulting application name: EXCEL.EXE, version 16.0.4266.1001, time stamp: 0x55ba1551 Faulting module name: BBjODBC.dll, version 14.1.1.0, time stamp: 0x5400df87 Exception code: 0xc0000005

这确认问题出在 BBj 驱动程序上.事实证明,负责更新该驱动程序的人员已在服务器的所有硬盘驱动器上更新了它,但 C 驱动器除外,这是 Excel 决定使用的驱动器.结果,尽管我们的技术人员声称一切都是最新的,但我们仍然坚持使用 5 年前的驱动程序版本.我们目前正在等待驱动程序更新,希望这能解决问题.

This confirmed that the problem was with the BBj driver. It turns out that the person responsible for updating that driver had updated it on all of the server's hard drives except for the C drive, which was the one that Excel decided to use. As a result, we were stuck using a five year old version of the driver even though our tech people claimed everything was up to date. We're currently waiting for the driver to be updated, so hopefully that will fix the issue.

这篇关于在 Excel 升级后评估 EOF 时 ADO 记录集崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆