title: SqlDataReader is not returning all rows
body: <p>My SQL command returns 3 rows which is verified in a SQL Server GUI. I run the exact same code and the SqlDataReader only returns 2 of them. The same sql command returns 3 rows with <code>SqlDataAdapter</code>.</p>
  
  <p>Here is my code - <code>ds</code> has 3 rows. Just to show the difference, I have added <code>SqlDataAdapter</code>.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["VPO"].ConnectionString))
  {
      string sql = "SELECT DISTINCT A.account_id, A.fname, A.lname, 
                    FROM T_Test1 A WITH (NOLOCK) 
                    JOIN T_Test2 AF WITH (NOLOCK) ON A.Account_id=AF.Account_id
                    WHERE account_status = 'A' AND A.card IS NOT NULL
                      AND A.dateFrom &gt;= '09-02-2013 00:00:00' 
                      AND A.dateFrom &lt;= '09-30-2013 00:00:00' 
                      AND AF.code = 'INE'";
  
      SqlCommand command = new SqlCommand(sql.ToString(), connection);
      command.CommandTimeout = 3600;
  
      connection.Open();
  
      using (SqlDataReader reader = command.ExecuteReader())
      { 
          while (reader.Read())
          {}
      }
  
      DataSet ds = new DataSet();
  
      SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
      da.Fill(ds);
  }
  </code></pre>
  
  <p>I found the solution:
  One of the line in using section is reading the first record. In while loop, it is reading from second record. I removed the below if condition and it worked fine. Thank you all for your replies. Sorry for not posting that line, as I thought that line is handling only exception.</p>
  
  <pre><code>if (!reader.Read()) 
      throw new ApplicationException("MISSING Transaction Returned By Financial Institution. Transaction was not found in the database."); 
  while (reader.Read()) {}
  </code></pre>