C#中的超时异常 [英] Timeout Exception in C#

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

问题描述

在SQL中执行一个过程需要50秒才能完成并返回5000条记录。



当我在C#中使用Linq调用相同的程序时,它会抛出超时异常,下面是详细信息。



System.Data.SqlClient.SqlException:超时已过期。操作完成前经过的超时时间或服务器没有响应。



请帮我解决问题。



谢谢。

Executing a procedure in SQL takes 50 seconds in getting completed and returns 5000 records.

when I call same procedure using Linq in C#, it throws Timeout Exception, below is the detail.

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Please help me how to fix it.

Thanks.

推荐答案

在查询之前尝试设置连接超时:



http:// msdn。 microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout%28v=vs.110%29.aspx [ ^ ]
Try setting the timeout on your connection before querying :

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout%28v=vs.110%29.aspx[^]


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

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