If the exception is:
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

It means Command is taking long in the database and has been killed. The default time of 30 seconds should be increased by using the "CommandTimeout" field on the "Command" object.


SqlCommand sqlcom = connection.CreateCommand();
sqlcom.CommandTimeout = 60; // Increase according to requirement
sqlcom.CommandText = sqlText;

Related Articles

Try... Catch in SQL

Try Catch in SQL is the one of the best option to be used with the transaction. We can begin the Transaction immediate after the Begin try and at the end the try we can commit the transaction. It means all the Queries inside the Try executed successfully. And inside the Catch, we can rollback the Transaction since the catch will be executed only if there as there some exception occurs and all or some of the queries inside the try is not executed.

More articles: SQL exception SQL 2008 features


Author: parvathy25 Nov 2010 Member Level: Bronze   Points : 1


apply in the settings of sqlsever...
an option and set timeout there to 600 or something

also in the connection string apply pool=false


or not need to write timeout just give timeout=600 in the settings of sqlserver

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: