执行查询时出现超时错误 [英] Time out error while executing the query

查看:54
本文介绍了执行查询时出现超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在存储过程中执行以下查询,将一年的事务从一个表转移到另一个表:

I am executing the following query in a stored procedure, transferring one year's transactions from one table to another:

insert into 
    table2 
select
    * 
from 
    table1 
where 
    dates between '20110101' and 20111231'

当我使用 VB6 调用存储过程时,它超时了.

When I use VB6 to call the stored procedure, it times out.

我尝试将 RDO 连接上的 QueryTimeout 属性设置为 5 秒,如下所示:

I've tried to set the QueryTimeout property on my RDO Connection to five seconds like so:

RdoConn.QueryTimeout = 5000

但它仍然超时.

如何防止查询的执行超时?

How can I prevent the execution of the query from timing out?

推荐答案

如果您使用 Ado 连接,您可以使用以下代码

If you use an Ado connection you can use the following code

dim myConn 
Set myConn = CreateObject("ADODB.Connection") 
myConn.CommandTimeout = 3600
myConn.ConnectionTimeout = 3600

然后使用此连接来执行您的查询.

and then use this connection to execute your query.

您的查询运行没有问题需要多长时间?

更新:
使用RdoConnection,您可以尝试设置事件LoginTimeout

Update:
Using RdoConnection, you can try to set event the LoginTimeout

RdoConn.QueryTimeout = 5000
RdoConn.LoginTimeout = 5000

或者如Oleg Dok所指出的那样

RdoConn.QueryTimeout = 0 'disable timeout
RdoConn.LoginTimeout = 0 'disable timeout

这篇关于执行查询时出现超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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