2017-05-06 53 views
1

我有一个表包含100列和2,000,000条记录asp.net mvc中的等待操作超时4

当我使用存储过程从中获取记录时,有时我得到“等待操作超时。”错误。当我改变存储过程并尝试获取记录时,它工作正常。

任何人都可以让我知道什么是最好的解决方案吗?

回答

0

SQL服务器的默认查询超时设置为30秒。

详情click here

0

由于维沙尔奈克已经提到,SQL服务器具有30秒的默认查询超时时间设置。一个可能的解决方案是手动增加给定查询的这段时间,这虽然不被推荐,但应该是有效的。代码如下:

SqlCommand cmd = new SqlCommand(commandText, conn); 
cmd.CommandTimeout = 60; // or any other length of time in seconds 
/*Any other properties to be modified in the command will come here*/ 
SqlDataReader dataReader = cmd.ExecuteReader(); 
+0

谢谢yash。我们可以在全球设置commandTimeout属性吗? –

+0

@YogeshKhurpe不幸的是,你不能从配置中改变CommandTimeout属性。 – YashTD