0

我正在使用 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 
4

1 回答 1

2

是否更改命令超时取决于几件事。它认为您应该首先花一些时间找出超时发生的原因:

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

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

于 2012-06-01T11:33:51.717 回答