Wednesday, November 7, 2012

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

By default the timeout of an SQL 'statement' is set to 30 seconds. If SQL Server takes more than 30 seconds to complete your task, you'll receive a timeout. You may want to set the timeout yourself. The timeout property is called CommandTimeout, it's a property of the SqlCommand object.

Using myCommand As New SqlCommand()
 ' Set the new command timeout to 60 seconds
 ' in stead of the default 30
 myCommand.CommandTimeout = 60
End Using
 
or
 
using (SqlCommand myCommand = new SqlCommand())
{
   // Set the new command timeout to 60 seconds
   // in stead of the default 30
   myCommand.CommandTimeout = 60; 
} 

No comments:

Post a Comment