簡體   English   中英

The wait operation timed out Win32Exception (0x80004005): The wait operation timed out azure

[英]The wait operation timed out Win32Exception (0x80004005): The wait operation timed out azure

從 sql azure 檢索大量數據時出現以下錯誤。 我已經實現了瞬態故障處理,但仍然收到此錯誤

說明:在執行當前 Web 請求期間發生未處理的異常。 請查看堆棧跟蹤以獲取有關錯誤及其起源於代碼的更多信息。

異常詳細信息:System.ComponentModel.Win32Exception:等待操作超時

源錯誤:

執行當前 Web 請求期間生成了未處理的異常。 可以使用下面的異常堆棧跟蹤來識別有關異常來源和位置的信息。

堆棧跟蹤:

[Win32Exception (0x80004005): 等待操作超時]

[SqlException (0x80131904): 超時已過期。 操作完成之前超時時間已過或服務器未響應。] System.Data.SqlClient.SqlConnection.OnError(SqlException 異常,布爾中斷連接,操作1 wrapCloseInAction) +1789270 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) +5340622 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244 System.Data.SqlClient.TdsParCommander.TryHandler,SqlData. dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1691 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +275 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds,Command Behavior RunExecuteReaderTds(布爾返回流、布爾異步、Int32超時,Task& 任務,布爾 asyncWrite,SqlDataReader ds) +1421 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String 方法, TaskCompletionSource 1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +177 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource 1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +208 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +163 System.Web.SessionState.SqlSessionStateStore.SqlExecuteNonQueryWithRetry (SqlCommand cmd, Boolean ignoreInsertPKException, String id) +98

[HttpException (0x80004005): 無法連接到 SQL Server 會話數據庫。] System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection conn, Exception e) +235 System.Web.SessionState.SqlSessionStateStore.SqlExecuteNonQueryWithRetry(SqlCommand cmd, Boolean ignoreInsertPKException, String id) +390 System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +589 System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +565 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&completedSynchronously) +69

版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34009

http://i.stack.imgur.com/8BloW.png

SqlClient.SqlCommand 對象有一個屬性 CommandTimeout。 它的默認值為 30(秒)。 您應該將其設置為更高的值。

您可以將超時值設置得更高,也可以關閉超時值,就像我在下面的代碼中所做的那樣。 請注意,如果保存數據的對象超過 2Gb,您可能會遇到錯誤。 您可能需要考慮重新設計您的查詢以一次獲取較小的數據塊。

// I'm populating an ADO.Net DataTable for this demo but populate whatever object you'd like
DataTable DtFromSQL = new DataTable();
SqlConnection myConnection = new SqlConnection("ConnectionString");
myConnection.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("enter some SQL query here", myConnection);
// A CommandTimeout Value of 0 turns the timout off, otherwise you can set it to some value in seconds
myCommand.CommandTimeout = 0;  
myReader = myCommand.ExecuteReader();
DtFromSQL.Load(myReader8);
myConnection.Close();
DtFromSQL;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM