为什么变化的CommandTimeout不工作 [英] Why change in CommandTimeout not working

查看:508
本文介绍了为什么变化的CommandTimeout不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用实体框架和ADO.net MVC2应用。在ADO.net SqlCommand的方面,它得到的,

I have MVC2 application using Entity Framework and ADO.net. In ADO.net SqlCommand connection, it get,

在/应用程序中的服务器错误。 超时已过期。之前完成操作已过或服务器超时期间没有响应。

Server Error in '/' Application. Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

在code是,

using (SqlCommand command = conn.CreateCommand())
{
    var commandText = "exec 'stored producedure name'";
    command.CommandTimeout = 240;

    SqlDataAdapter da = new SqlDataAdapter(commandText, conn);
    DataSet ds = new DataSet();
    da.Fill(ds, "Table");
}

存储过程大约需要3分钟才能完成。所以我改变的CommandTimeout从默认的30秒240秒(4分钟)。然而约30第二动后,仍然得到超时的错误。它看起来看的CommandTimeout不工作。在code运行在VS 2010如何更改命令超时?

The stored procedure takes about 3 mins to complete. So I change CommandTimeout to 240s (4 mins) from default 30s. However it still gets "Time out" error after about 30 second running. It looks look CommandTimeout is not working. The code runs in VS 2010. How to change the command timeout?

推荐答案

您在此处设置的超时为超时您使用的驱动程序。也许你有你的SQL服务器本身就是一个超时设置。打开SQL Management Studio中,连接到SQL服务器,并用鼠标右键单击属性下的选项来检查,如果你设置其他超时那里。将其设置为你的prefered价值在那里。

The timeout you set here is the timeout for the driver you use. Maybe you have a timeout setting in your SQL server itself. Open the SQL management studio, connect to the SQL server and right click on properties to check under options if you set another timeout there. Set it to your prefered value there.

这篇关于为什么变化的CommandTimeout不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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