我正在使用C#对SQL数据库进行大量操作。
但是我一直遇到以下的超时异常:
System.Data.SqlClient.SqlException:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.
我运行了大量查询(超过100k),并且没有任何一个特定的查询会导致异常 - 有时我可以完成所有查询而不出现异常。
其中一些异常来自作为更大事务的一部分运行的查询,另一些来自单独运行的查询。
当我直接在SQL Server Management Studio中运行相同的查询时,它们只需要不到一秒钟的时间来运行。
我使用相同的SQLConnection对象进行所有查询,但对于每个查询都使用新的SQLCommand对象。
当我尝试使用SQL Server Profiler时,它只显示批处理/RPC已经完成。
为什么我会随机收到此异常?
sp_who4
显示实际查询:http://saji-sqlsolutions.blogspot.com/2013/04/spwho4.html - Máster