如何模拟 ODBC 超时错误?
我正在测试 Access-VBA 控制进程的错误处理:
- Access“控制器”数据库中的脚本启动。
- 该脚本在第二个 Access 文件(“数据库”)中启动一个宏。
- “数据库”文件中的宏运行一堆可生成的查询。
- 这些查询从链接到 ODBC 源(实际上是 SQL-Server)的表中提取。
当此进程在凌晨运行时,有时查询会超时。今天,我更新了控制器脚本中的错误处理,因此我想模拟超时错误。
我查看了 MS Access 中的 ODBC 管理器和高级选项,但没有找到我需要的内容。有想法吗?
I am testing the error-handling of an Access-VBA controlled process:
- A script in an Access 'controller' DB starts.
- The script starts a macro in a 2nd Access file (the 'database').
- The macro in the 'database' file runs a bunch of maketable queries.
- These queries pull from tables linked to an ODBC source (SQL-Server actually).
When this process runs in the early morning hours, sometimes the queries time out. Today, I've updated the error-handling in the controller script, so I want to simulate a time-out error.
I've looked at the ODBC administrator and Advanced options in MS Access, but I'm not finding what I need. Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您的查询是修改的,您可以添加一个调用 WAITFOR 的触发器。 此处描述。
If your queries are modifications, you can add a trigger which invokes WAITFOR. Described here.
在 SQL 查询中添加以下语句 - 它应该会导致超时。
或者,如果您不想修改现有查询,您可以在宏查询的表之一上运行此查询。这将锁定表 3 分钟
Within your SQL Queries add the following statement - it should cause a timeout.
Or if you don't want to amend existing queries you can run this over one of the tables that the macro queries. This will lock the table for 3 mins
在设计视图中打开宏。在“视图”菜单下,选择“属性”。
它应该是一个超时属性,将其设置为一个短值并进行测试。
Open your macro in design view. Under the View menu, select Properties.
It should be a Timeout property, set it to a short value and test.
回复:有时查询会超时。
请确保 ODBC 超时的查询属性设置为零,这样它就不会生成错误但会继续运行。
re: sometimes the queries time out.
Make sure your query property for ODBC timeout is set to zero so it doesn't generate an error but continues running.