I had an Asp.Net Application to manually a very complicate Database Update against the SQL Server.
But the Test always failed with Sql conncection Timeout Error
Exception Type: System.Data.SqlClient.SqlException
Exception: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated.
Source: Save Data
Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at CustomerDataDeduplicationDataAccess.CustomerDataDeduplicationDA.SaveMasterRecord(CustomerDataDeduplicationBE customerData, String[] duplicatedRecordProspectList, String userName) in C:\Users\ddeng\Documents\Visual Studio 2005\Projects\AS400ToSQL\CustomerDataDeduplication_Web\CustomerDataDeduplicationDataAccess\CustomerDataDeduplicationDA.cs:line 422
Target Site: Void OnError(System.Data.SqlClient.SqlException, Boolean)
Initially I try to increase the execution Timeout in the Code Level
sqlCommand.CommandTimeout = 600;
However the issue still persistent. I try to set the connection Timeout in the code as well.
I received a compilation Error that sql connectio TimeOut Property is ready. we are not able to modify it
from the code.
the Solution is we should modify the Default Connection Time out in the connection string.
here is the fix that i performed in the Web.config file.
connectionString="Server=SQLSeverName; Initial Catalog=MyDatabase; Integrated Security=SSPI; Connection Timeout=600"
the connection time will increase from Defualt which is 15 Second to 10 minutes
Try this in your web.config,
ReplyDelete<addkey value="server=LocalHost;uid=sa;pwd=;database=DataBaseName;Connect Timeout=200; pooling='true'; Max Pool Size=200" />
Alternatively, try to Select Top 50 or less records in your SQL Statement