SQL 增加.net中的Sql超时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3985656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 08:00:33  来源:igfitidea点击:

Increase Sql timeout in .net

sql.net-services

提问by Zerotoinfinity

I am gettting SQL time out error in my .net service.

我的 .net 服务中出现 SQL 超时错误。

As the service is already installed on the production, is there any way I can increase the timeout for the service from App.Config file.

由于该服务已安装在生产中,有什么方法可以从 App.Config 文件中增加该服务的超时时间。

At present, I am getting this exception after one minute, I have to make it to around 10 hours because the stored procedure we are using takes 2-2 hours to execute.

目前,我在一分钟后收到此异常,我必须使其达到大约 10 小时,因为我们使用的存储过程需要 2-2 小时才能执行。

采纳答案by Statler

You can set the timeout in your connection string with "connect Timeout = 100000000;" or whatever you want your timeout to be

您可以使用“connect Timeout = 100000000;”在连接字符串中设置超时。或者任何你想要的超时时间

回答by Darin Dimitrov

You could try setting the CommandTimeoutproperty on your SqlCommand. I hope you are not doing this in an ASP.NET application.

您可以尝试在SqlCommand上设置CommandTimeout属性。我希望您不是在 ASP.NET 应用程序中这样做。

回答by Damian Leszczyński - Vash

The time out setting is up to database server.

超时设置取决于数据库服务器。

In SQL Server Manager open the SQL Server Properties and pick the connection tab and set time out as big as You need.

在 SQL Server 管理器中打开 SQL Server 属性并选择连接选项卡并根据需要设置超时。

Ps.

附言。

zero goes for no timeout.

零表示没有超时。