mysql连接字符串 超时_s数据库连接字符串超时的问题

当使用SqlHelper或SqlClient Class执行长时间SQL操作时,可能会遇到超时问题。超时异常显示为'Timeout expired...the server is not responding'。尽管在连接字符串中设置了Connect Timeout,但实际超时是由SqlCommand.CommandTimeout而非SqlConnection.ConnectionTimeout引起的。SqlCommand.CommandTimeout默认为30秒,而SqlConnection.ConnectionTimeout默认为15秒。解决方法是在SqlCommand对象上设置CommandTimeout属性。
摘要由CSDN通过智能技术生成

错误原因:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

感谢作者:

今天碰到了一个查询异常问题,上网查了一下,感谢原创和译者

如果你使用的数据库连接类是 the Data Access Application Blocks "SqlHelper" 或者 SqlClient Class , 你在执行一个很费时的SQL 操作时候,可能就会碰到下面的超时异常。

---------------------------

---------------------------

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

---------------------------

OK

---------------------------

你会说,我在连接字符串中已经 设置了 Connect Timeout=80000 ,并且数据库中超时连接也是设置的值是一个很大的值。为啥到了30秒,仍然超时了呢??

这是因为:

你的设置并没有问题,是你混淆了 SqlCommand.CommandTimeout 和 SqlConnection.ConnectionTimeout 这两个的区别了。

你的连接字符串中的超时只是设置的 SqlConnection.ConnectionTimeout 的值,而不是设置的 SqlCommand.CommandTimeout 的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值