超时过期的SQL Server问题 [英] Timeout expired sql server problem

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

问题描述

我在SQL Server上需要30秒到40秒才能返回数据的查询
我尝试从我的页面致电的地方
它给我那个错误

超时时间已到.在操作完成之前超时时间已经过去,或者服务器没有响应.

i have query that take from 30 second to 40 second on sql server to return data
where i try to call from my page
it give me that error

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

推荐答案

请参阅以下内容:
http://forums.asp.net/t/1343831.aspx/1 [ ^ ]

Refer to this:
http://forums.asp.net/t/1343831.aspx/1[^]

http://sqlserverplanet.com/troubleshooting/fix-timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation-or-the-server-is-not-responding[^]


由于您可能正在使用SqlCommand来调用查询,您可以指定该超时时间:

As you are probably using a SqlCommand for calling the query, you can specify the timeout for that one:

using (SqlConnection cn = new SqlConnection(Configuration.DefaultConnectionString))
{
    using (SqlCommand cmd = new SqlCommand(query, cn))
    {
        cmd.CommandTimeout = 60;
        cn.Open();
        ...



或在web.config中指定连接超时(我不建议这样做).

在此处的更多信息
http://msdn. microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout(v=vs.110).aspx [



Or specify the timeout for the connection in the web.config (which I will not recommend).

More info here http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout(v=vs.110).aspx[^]


Cheers


您可以在长时间运行的查询的连接字符串中设置Connection Timeout = value(可能以秒为单位,或者Millisec不能记住)来实现此目的
祝你好运.....
You can set the Connection Timeout=value(may be in sec or millisec can''t remember) in connection string for the long running query to achieve this
best of luck.....


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

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