Monday, November 12, 2007

Timeout Expired in ASP .NET


This error occurs when a database query or stored procedure’s execution time beyond a pre-set timeout period. When you are trying to retrieve a huge amount of data, more execution time may be required.

There are 2 main Timeout properties in .NET:
1. Connection Timeout – It could be solved by setting ConnetionTimeout property in your connection string. For example:
<add key="DBConnection" value="server=localhost;uid=sa;pwd=;database=dbName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>

2. Timeout for Data Access (Command Object) – You can set a CommandTimeout property to your Command object. For example:
public void CreateMySqlCommand() {
SqlCommand myCommand = new SqlCommand();
myCommand.CommandTimeout = 15;
myCommand.CommandType = CommandType.Text; }

or if you are using data adapter instead of SqlCommand, you can get the Timeout property via: DataAdapter.SelectCommand.CommandTimeout

0 comments:

 

Get paid for your opinions! Click on the banner above to join Planet Pulse. Its totally free to sign up, and you can earn UNLIMITED. Find out more by visiting PLANET PULSE.
Sign up for PayPal and start accepting credit card payments instantly. http://www.emailcashpro.com
July Code Blog Copyright © 2010 Blogger Template Designed by Bie Blogger Template