title: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
body: <p>I am using a stored procedure to retrieve a record and display it in a grid.</p>
  
  <p>The first time around, it will throw an exception:</p>
  
  <blockquote>
    <p>Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.</p>
    
    <p>Stack trace</p>
    
    <p>at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)<br>
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)<br>
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()<br>
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)<br>
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()<br>
    at System.Data.SqlClient.SqlDataReader.get_MetaData()<br>
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)<br>
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)<br>
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)<br>
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)<br>
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)<br>
    at System.Data.SqlClient.SqlCommand.ExecuteReader()  </p>
  </blockquote>
  
  <p>I used </p>
  
  <pre><code>SELECT * 
  FROM sys.dm_tran_session_transactions
  </code></pre>
  
  <p>to check how many active transactions are currently in my database and I found none.</p>
  
  <p>For the second time onwards this stored procedure run perfectly (will not throw the timeout exception). What may be the cause of this behavior?</p>