SqlCommand对象,什么时间进行的CommandTimeout长度是多少? [英] SqlCommand object, what length of time for CommandTimeout?

查看:3689
本文介绍了SqlCommand对象,什么时间进行的CommandTimeout长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何决定什么时间作为超时使用长度使用SqlCommand对象时?

How do I decide what length of time to use as a timeout when using an SqlCommand object?

在的code我的工作零件(写别人)我有:

On parts of the code I'm working on (written by somebody else) I have:

cmd.CommandTimeout = 60;

我认为这是相当短。但是,我看到一些人在论坛上谈论它设置为30000,这似乎太长了。

Which I think is quite short. However, I have seen some people in forums talking about setting it to 30000, which seems too long.

我怎么知道什么是最适合我的应用?

How do I know what is best for my application?

推荐答案

人们似乎都搞不清楚,这是否是秒或毫秒。该<一href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx">documentation指出,超时以秒为单位。 1分钟超时似乎是合理的大多数查询。一个8+小时超时的的似乎是合理的。

It seems that people are confused as to whether this is seconds or milliseconds. The documentation states that the timeout is in seconds. A 1-minute timeout seems reasonable for most queries. An 8+ hour timeout doesn't seem reasonable.

你有你期待拿一分钟长的查询?如果是这样,将其抬高,您预计会比任何你会看到,如果一切工作正常高值,但不会高到采取永远提醒您注意的一个问题。 (例如,你可能会去从1分钟到5分钟。)

Do you have queries you're expecting to take longer than a minute? If so, raise it to a value you expect to be higher than anything you'd see if everything is working properly, but not so high as to take forever to alert you to a problem. (For example, you might go from 1 minute to 5 minutes.)

这篇关于SqlCommand对象,什么时间进行的CommandTimeout长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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