我有以下连接字符串(从sql server的属性获取):
Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\myUser\Desktop\adoBanche\Banche\bin\Debug\banche.mdf;Integrated Security=True;Connect Timeout=30
我不明白Timeout=30
是什么意思.有人能解释什么意思吗?
我有以下连接字符串(从sql server的属性获取):
Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\myUser\Desktop\adoBanche\Banche\bin\Debug\banche.mdf;Integrated Security=True;Connect Timeout=30
我不明白Timeout=30
是什么意思.有人能解释什么意思吗?
这是连接的超时时间,而不是该连接执行的命令的超时时间.
例如,见http://www.connectionstrings.com/all-sql-server-connection-string-keywords/
从 comments 中可以看出:
无法通过连接字符串设置命令超时.但是,SqlCommand有一个CommandTimeout属性(源自DbCommand),您可以在其中设置每个命令的超时(以秒为单位).
请注意,当使用Read()
循环查询结果时,每次读取时都会重置超时.超时是针对每个网络请求,而不是针对整个连接.