开发者

Timeout error in VB.NET while running a sql script

开发者 https://www.devze.com 2023-02-06 00:55 出处:网络
I was wondering if someone can help me figure why I am getting this error from a simple stored procedure that I created in SQL Server 2008 R2.I am trying to obtain data and insert it into a temporary

I was wondering if someone can help me figure why I am getting this error from a simple stored procedure that I created in SQL Server 2008 R2. I am trying to obtain data and insert it into a temporary table. if it is a timeout issue, how can I increase the timeout length to 420 seconds. to my understanding the timeout is good for only 30 seconds.

this is the error in its entirety:

Server Error in '/WebSite9' Application.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.开发者_开发知识库Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394 System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33 System.Data.SqlClient.SqlDataReader.get_MetaData() +83 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1297 System.Web.UI.WebControls.BaseDataList.GetData() +38 System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +153 System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +54 System.Web.UI.WebControls.BaseDataList.DataBind() +55 System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +60 System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69 System.Web.UI.Control.EnsureChildControls() +87 System.Web.UI.Control.PreRenderRecursiveInternal() +44 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955


Dim cmd = connection.CreateCommand()    
cmd.CommandTimeout = 420

Use the CommandTimeout property.


Set the timeout in ASP code

VB.NET:

Dim objCmd = conn.CreateCommand()
objCmd.CommandTimeout = 420

or Classic:

set con = createObject("ADODB.Connection")
con.open connectionString
con.commandTimeout = 420

I would review your execution plan on your query as well to determine if you have some table scans going on resulting in a poor performing query.

0

精彩评论

暂无评论...
验证码 换一张
取 消