SqlException


SqlException

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)

solution
--------
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.

e,g

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

Comments

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

http://www.connectionstrings.com/Articles/Show/all-sql-server-connection-string-keywords


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


also in the connection string apply pool=false


http://authors.aspalliance.com/aspxtreme/sys/data/sqlclient/SqlConnectionClassConnectionString.aspx




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:
    Email: