.net 连接字符串中 ConnectTimeout 的默认值是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9158695/
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
What's the default value of ConnectTimeout in connection string?
提问by Zalan
If we dont set the ConnectTimeout value, e.g. "Connect Timeout=60", (neither in SqlCommand), what's the dafault value it will be? I was told it's 15s
如果我们不设置 ConnectTimeout 值,例如“Connect Timeout=60”,(在 SqlCommand 中都没有),它的默认值是多少?我被告知是 15 秒
Thanks
谢谢
回答by Enrico Campidoglio
The default connection timeoutin SqlClientis 15 seconds.
该默认连接超时中的SqlClient是15秒。
回答by Jon Skeet
From the SqlConnection.ConnectionTimeoutdocs:
从SqlConnection.ConnectionTimeout文档:
The time (in seconds) to wait for a connection to open. The default value is 15 seconds.
等待连接打开的时间(以秒为单位)。默认值为 15 秒。
回答by dougajmcdonald
I believe it's 30 seconds, default on MS SQL Server
我相信它是 30 秒,默认在 MS SQL Server 上
EDIT: as others have corrected me, 15 seconds is the default.
编辑:正如其他人纠正我的那样,默认值为 15 秒。
Doh, my bad! apologies!
哦,我的错!道歉!

