Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试为数据库连接设置计时器。基本上,如果 X 秒后连接没有响应,我希望连接方法停止,并使用 C# .NET 中的 Winforms 返回警告。
connection.ConnectionTimeout 属性是您真正需要的。
获取在尝试建立连接时等待的时间,然后终止尝试并生成错误。 https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout(v=vs.110).aspx
获取在尝试建立连接时等待的时间,然后终止尝试并生成错误。
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout(v=vs.110).aspx