连接字符串中的连接超时属性被忽略 [英] connection timeout property in connection string ignored

查看:59
本文介绍了连接字符串中的连接超时属性被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#构建应用程序。我使用的连接字符串如下:

I'm building an app in C#. I'm using a connection string like:

DSN=SomeDataSource; Trusted Connection = yes; Uid=SomeId; pwd=somePwd; Connection Timeout=x

但是无论我将 x设置为什么值 Connection Timeout = x ),通过放置一个断点,我可以看到我的 DbConnection 对象的 ConnectionTimeout 属性始终具有默认值 15

But no matter what value I set as x (Connection Timeout = x), by putting a breakpoint, I can see that my DbConnection object's ConnectionTimeout property always has the default value 15.

谢谢。

推荐答案

ConnectionString中的code>连接超时仅控制连接的超时。如果需要增加命令的等待时间,请使用SqlCommand的 CommandTimeout 属性。

The Connection Timeout in the ConnectionString only controls the timeout for the connection. If you need to increase the wait time on your Commands, use the CommandTimeout property of SqlCommand.

这篇关于连接字符串中的连接超时属性被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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