SQL Server:超时已过期

时间:2012-06-01 11:21:03

标签: asp.net sql-server

我正在使用MS SQL Server 2008,我收到以下错误。我怎样才能解决这个问题?你们认为将Timeout设置为60秒是一个好方法吗?

感谢您的时间,

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Stack Trace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at 
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
 at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at Karkas.Core.DataUtil.HelperFunctions.SorguCalistir(DataTable dt, SqlCommand cmd) at Karkas.Core.DataUtil.HelperFunctions.SorguCalistir(DataTable dt, String sql, CommandType cmdType, SqlParameter[] parameters) at Karkas.Core.DataUtil.AdoTemplate.DataTableDoldur(DataTable dataTable, String sql, CommandType commandType, SqlParameter[] parameters) at Karkas.Core.DataUtil.AdoTemplate.DataTableOlustur(String sql, SqlParameter[] parameters) at 

1 个答案:

答案 0 :(得分:2)

是否更改命令超时取决于几个方面。它认为你应该首先花一些时间找出为什么首先发生超时:

  • 您是否一次性获取太多信息?
  • 你能以某种方式提高表现吗?也许在相关表上添加som索引?
  • 是否有其他进程(或其他进程)锁定表,阻止查询

在找出原因之后,您可以决定增加命令超时是否正确。但特别是如果问题是由于外部进程阻塞,我会非常犹豫是否会增加超时。这可能会使问题变得更糟。