SQLClient命令超时 [英] SQLClientcommand timeout

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

问题描述


感谢您对以下文章的帮助:

更改LINQ DataContext的默认CommandTimeout

有没有一种方法可以以单一全局方式更改SQLClient命令超时?

问候,
Bond Ridhoo.

Hi,
Thanks for your helpful article on:

"Change The Default CommandTimeout of LINQ DataContext

Is there a way to change the SQLClient command timeout in a single global way?

Regards,
Bond Ridhoo.

推荐答案

重写DataContext类的OnCreated()方法,并使用类似以下内容的方法:
Override the OnCreated() method of the DataContext class and use something like the following:

partial void OnCreated()
{
    CommandTimeout = 60; // Use appropriate number.
}


Bond

这里需要注意的几件事:

1.发表文章时,习惯上针对文章发表问题.在这里,在快速解答"部分中,它会丢失上下文.
2.您不应该考虑全局更改超时,而是尝试更改连接到数据库的所有应用程序的超时.
3.您可以将命令超时指定为连接字符串的一部分.您只需要添加"Connect Timeout"="30" 即可获得30秒的连接超时.
Bond

A few things to note here:

1. When you are posting about an article, it''s customary to actually post the question against the article. Here, in the quick answers section, it loses context.
2. You should not be thinking about changing the timeout globally as you would be attempting to change the timeout for ALL applications that connect to the database.
3. You can specify the command timeout as part of the connection string. All you need to is add "Connect Timeout"="30" to get a 30 second timeout on the connection for instance.


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

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