如何模拟 ODBC 超时错误?

发布于 2024-09-24 15:41:15 字数 315 浏览 1 评论 0原文

我正在测试 Access-VBA 控制进程的错误处理:

  1. Access“控制器”数据库中的脚本启动。
  2. 该脚本在第二个 Access 文件(“数据库”)中启动一个宏。
  3. “数据库”文件中的宏运行一堆可生成的查询。
  4. 这些查询从链接到 ODBC 源(实际上是 SQL-Server)的表中提取。

当此进程在凌晨运行时,有时查询会超时。今天,我更新了控制器脚本中的错误处理,因此我想模拟超时错误。

我查看了 MS Access 中的 ODBC 管理器和高级选项,但没有找到我需要的内容。有想法吗?

I am testing the error-handling of an Access-VBA controlled process:

  1. A script in an Access 'controller' DB starts.
  2. The script starts a macro in a 2nd Access file (the 'database').
  3. The macro in the 'database' file runs a bunch of maketable queries.
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

笔落惊风雨 2024-10-01 15:41:16

如果您的查询是修改的,您可以添加一个调用 WAITFOR 的触发器。 此处描述。

If your queries are modifications, you can add a trigger which invokes WAITFOR. Described here.

风筝有风,海豚有海 2024-10-01 15:41:16

在 SQL 查询中添加以下语句 - 它应该会导致超时。

--waits for 5 mins
    WaitFor Delay '00:05'

或者,如果您不想修改现有查询,您可以在宏查询的表之一上运行此查询。这将锁定表 3 分钟

begin transaction

Select *
From MyTable with (TABLOCKX)
--wait for 3 min
WaitFor Delay '00:03'

rollback transaction

Within your SQL Queries add the following statement - it should cause a timeout.

--waits for 5 mins
    WaitFor Delay '00:05'

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

begin transaction

Select *
From MyTable with (TABLOCKX)
--wait for 3 min
WaitFor Delay '00:03'

rollback transaction
谜兔 2024-10-01 15:41:15

在设计视图中打开宏。在“视图”菜单下,选择“属性”。
它应该是一个超时属性,将其设置为一个短值并进行测试。

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.

乖不如嘢 2024-10-01 15:41:15

回复:有时查询会超时。

请确保 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文