title: ADO.NET calling T-SQL Stored Procedure causes a SqlTimeoutException
body: <p>I have a T-SQL stored procedure with the signature</p>
  
  <pre><code>CREATE PROCEDURE MyProc
  @recordCount INT OUTPUT
  @param1 INT
  ...
  </code></pre>
  
  <p>When executed directly in Sql Server the procedure runs in under 5 seconds, returning a few result sets amounting to about 100 rows in total.</p>
  
  <p>Calling this procedure using the ADO.NET <code>SqlDataAdapter.Fill</code> method to populate a <code>Dataset</code> causes a <code>SqlTimeoutException</code> on the <code>SqlCommand</code> after 3 minutes (the specified timeout interval).</p>
  
  <p>Changing the stored procedure so that it no longer has an output parameter, and that the output value required is returned as the last result set, solves the problem, and the whole thing runs in under 5 seconds as expected.</p>
  
  <p>But why?</p>
  
  <p>I don't want to go through my code base and modify all instances of this type of behaviour without understanding if I have really solved the problem.</p>
  
  <p>Another thing to note is this is only apparent on one particular server, which admittedly has a larger dataset than other similar databases we run. Surely not a Sql Server setting?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Stepping into the framework source the issue appears to be in metadata retrieval. The <code>ConsumeMetaData</code> method of the <code>SqlDataReader</code> object hangs indefinitely. However I ran tests on other databases and cannot reproduce, so it is a database specific issue when this procedure is called though ADO.NET... Great.</p>
  
  <p><strong>UPDATE II</strong></p>
  
  <p>Have confirmed the issue still occurs if I change the code to use the <code>OleDbDataAdapter</code> with the SQLOLEDB or SQLNCLI provider types. Definitely to do with the connection.</p>