.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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:13:20  来源:igfitidea点击:

What's the default value of ConnectTimeout in connection string?

.net

提问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

回答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 Oybek

Your've been told correctly. Hereis the proof

你已经被正确告知。是证据

回答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!

哦,我的错!道歉!