从sql azure检索大量数据时出现以下错误。我已经实现了瞬态故障处理但仍然出现此错误
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.ComponentModel.Win32Exception:等待操作超时
来源错误:
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
堆栈追踪:
[Win32Exception(0x80004005):等待操作超时]
[SqlException(0x80131904):超时已过期。操作完成之前经过的超时时间或服务器没有响应。]
System.Data.SqlClient.SqlConnection.OnError(SqlException异常,Boolean breakConnection,Action 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.TdsParser.TryRun(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader 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(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async,Int32 timeout,Task& task,Boolean asyncWrite,SqlDataReader ds)+1421
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,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
答案 0 :(得分:0)
SqlClient.SqlCommand对象具有属性CommandTimeout。它的默认值是30(秒)。您应该将其设置为更高的值。
答案 1 :(得分:0)
您可以将超时值设置得更高,也可以关闭超时值,就像我在下面的代码中所做的那样。请注意,如果保存数据的对象超过2Gb,则可能会遇到错误。您可能需要考虑重新设计查询以一次获取较小的数据块。
<ScrollView
android:id="@+id/item_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
tools:visibility="visible">
<LinearLayout
android:id="@+id/item_wrapper_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/content_margin"
android:paddingBottom="32dp"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/item_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="@color/colorPrimary"
card_view:cardCornerRadius="4dp"
card_view:cardUseCompatPadding="true">