SQL命令excel VBA超时 [英] SQL Command excel VBA timeout

查看:1038
本文介绍了SQL命令excel VBA超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有谁能告诉我如何使用以下记录集连接和打开字符串将命令超时设置为0或任何其他数字?

Hi,
Can anyone tell me how to set the command timeout to 0, or any other number for that matter using the following recordset connection and open string?

objConn.Open "Driver={SQL Server}" & _
           "Server=x.x.x.x;" & _
           "Address=x.x.x.x,1433;" & _
           "Network=DBMSSOCN;" & _
           "Database=yyy;" & _
           "Uid=user" & _
           "Pwd=pass"

sSQL = "SELECT InvoiceYear, InvoiceMonth, InvoiceDay, InvoiceDate, InstituteName, CourseName, ItemNet , ItemTax FROM dbo.Table_Sales ORDER BY InvoiceDate"

rsData.Open sSQL, objConn, adLockReadOnly, adCmdText



非常感谢提前

Martin


Many thanks in advance
Martin

推荐答案

尝试将您的连接字符串更改为页面上的连接字符串。



也许将Connect Timeout参数设置为300秒(5分钟),如下所示:

Server = ServerName \InstanceName; Database = yyy; User Id = user;密码=通过;连接超时= 300;





或者你可以设置一个在ADO连接对象上找到的这些属性:

objConn。 ConnectionTimeout

objConn。 CommandTimeout
Try changing your connection string to one found on this page.

Perhaps setting the Connect Timeout parameter to 300 seconds (5min) like this:
"Server=ServerName\InstanceName;Database=yyy;User Id=user;Password=pass;Connection Timeout=300;"


Alternatively you could set one of these properties found on the ADO connection object:
objConn.ConnectionTimeout
objConn.CommandTimeout


如果有兴趣的话我设法通过更改问题来解决问题提供者

提供者= SQLNCLI10
In case anyone interested I managed to solve the problem by changing the provider
Provider=SQLNCLI10


这篇关于SQL命令excel VBA超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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