Solution for database execution timeout problem in ASP.Net application

2008-10-06

I am working on a web project to do the data transfer from an excel spreadsheet to MS SQL database. It updates around 15000 records on a monthly base.

I try to use a StringBuilder to build a long SQL command, then execute it in one go.

The following error occurs when I run the application:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

After some researches I set the CommandTimeout property in the code and solve the issue.

dbCommand.CommandTimeout = 3600; // 3600 seconds, dbCommand is DbCommand type which is used in Microsoft EnterpriseLibray.

Additional notes:

You may need to increase the ScriptTimeout property in your page as well.

In the page_load event simply use
Server.ScriptTimeout = 3600;

Make sure your set compilation debug="false" in web.config as well or the timeout setting will NOT take effect.
 


Previous Article:
Bring back the ChangePasswordTemplate from SuccessTemplate


Next Article:
Demonstration for web-based upload in ASP.Net



Categories

Search eGaWa.Blog

Keyword 1
Keyword 2
Keyword 3
Category
Search

Search Web

Reload Page