sql - 在 360 升级之前通过 SQL 查询更新 Excel 表的宏,现在给出错误
问题描述
我有一个电子表格,除其他外,它从各种输入单元格编写 SQL 查询、运行查询并更新数据。后端的 VBA 运行良好,但现在我已升级到 Office 360,我得到:
运行时错误“9”:下标超出范围。
这是VBA:
Sub Paid()
Dim strSQL As String
strSQL = Worksheets("SQL").Range("L6")
With ActiveWorkbook.Connections("Paid").OLEDBConnection 'here is the line that errors out
.BackgroundQuery = False
.CommandText = strSQL
End With
ActiveWorkbook.Connections("Paid").Refresh
End Sub
我直接在 SSMS 中仔细检查了 SQL,查询工作正常;虽然我不认为查询是问题,但它是这条线:
With ActiveWorkbook.Connections("Paid").OLEDBConnection
有没有人遇到过这个问题,知道如何让数据成功刷新吗?
解决方案
推荐阅读
- bash - 如何使用空格字符迭代值?
- ios - iOS 应用程序将数据从外部硬件传输到 iphone
- python - RelatedObjectDoesNotExist at /admin/login/ 用户没有个人资料
- cordova - Ionic iOS 构建失败,找不到错误存档
- spring-boot - Java 类强制转换异常 - 春季启动
- .net - Azure Cosmos DB GetById 查询不起作用
- java - Java不一致的逻辑乘以哈希码
- php - 如何在php中通过array_map传递原始HTML字符串而忽略HTML标签
- scala - 在 for-comprehension 中使用 if-guard 来检查是否存在
- android - com.android.server.autofill.RemoteFillService$PendingRequest.cancel() 上的 NPE