title: SqlDataReader times out when many records in SQL Server table
body: <p>I have stored procedure <code>Topounce</code> that gets the top record from a dynamic table and speaks it out of the PC. When the there are too many records it times out in </p>
  
  <pre><code>SqlDataReader dr2 = select.ExecuteReader() 
  </code></pre>
  
  <p>Right now there are around 750 records. I already tried <code>CommandTimeOut = 0</code> and it took around 10 min for the record to be spoken. Is there a way around this?</p>
  
  <p>Here is the error: </p>
  
  <blockquote>
    <p>Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>try
  {
     using (SqlConnection connStr2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString))
     {
        //Selects top record from vwAnno
        SqlCommand select = new SqlCommand("Topounce", connStr2);
        select.CommandType = CommandType.StoredProcedure;                   
        select.Parameters.AddWithValue("@ID", (string)Num);
  
        connStr2.Open();
  
        SqlDataReader dr2 = select.ExecuteReader();   // TIMES OUT HERE
  
        //Reads record in vwAnnounce
        while (dr2.Read())
        {
            //do work
        }
  
        dr2.Close(); //Close Datareader connection
        connStr2.Close();
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  here is the store procedure.</p>
  
  <pre><code>     USE [Queue]
        GO
        /****** Object:  StoredProcedure [dbo].[TopRowViewAnnounce]    Script Date:         06/01/2013 11:55:50 ******/
         SET ANSI_NULLS ON
       GO
       SET QUOTED_IDENTIFIER ON
       GO
       ALTER PROCEDURE [dbo].[TopRowViewAnnounce] 
      @QueueID int
  
      AS
  
  
      BEGIN
  
   SELECT TOP 1 id, qdate, ticket_number, QID, received, displaynum, station, transcodevoiced FROM vwAnnounce WHERE QID = @ID ORDER by received ASC
      END
  </code></pre>
  
  <p>The reason I did a store procedure its because I thought it was going to help the timeout. I originally had it like this.</p>
  
  <pre><code>SqlCommand select = new SqlCommand("SELECT TOP 1 id, qdate, ticket_number, QID, received, displaynum, station, transcodevoiced FROM vwAnnounce WHERE QID = @ID ORDER by received ASC", connStr2);
    select.CommandType = CommandType.StoredProcedure;                   
    select.Parameters.AddWithValue("@ID", (string)Num);
  
    connStr2.Open();
  
    SqlDataReader dr2 = select.ExecuteReader();   // TIMES OUT HERE
  </code></pre>
  
  <p>I still havent got the solution. Anybody?</p>