Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

This problem occur when we accessing the lagre data from the Asp.net application. It due to the execution time of the command of Ado.net.By default the execution time is 30 sec.If the execution takes more time it gives the Timeout expiration.

 If you specify the connection pooling to the database Connection also, it again give the timeout expiration.

 <add key=”defaultConnection” source=MyDatabase;database=mydata;uid=sa;pwd=123;

Pooling=true; Connect Timeout=300;Min Pool Size=5;Max PoolSiz=1000;”/>

In this Scenario the connection Timeout Specifies  the to establish the connection but not execution time.

 To solve this problem, increase the execution time of the Command .In Ado.net it provide a property Called CommandTimeout.This property is set and getable.To set the value specify in Seconds.

 For Command object 

cmd.CommandTimeout=60; (or)


 For Adapter

da.SelectCommand.CommandTimeout =180;

da.SelectCommand.CommandTimeout = connection.ConnectionTimeout;

 In SqlHelper class, we also specify the CommandTimeout.If take ExecuteDataset method, the final execution of the ExecuteDataset we specify the CommandTimeout.In this we specify either command or   Adapter to set commandTimeout.

 public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)



cmd.CommandTimeout=60; (or)



da.SelectCommand.CommandTimeout =180;

da.SelectCommand.CommandTimeout = connection.ConnectionTimeout;


This entry was posted in Articles. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s