title: Getting "Invalid attempt to call Read when reader is closed"
body: <p>I've got the following code (here with pseudovalues for readability), where the first connection returns a lot of data (thousands of rows). SqlDataReader reads them one by one by the <code>reader.Read()</code> and then opens a new connection to update each row with new values:</p>
  
  <pre><code>using (SqlConnection conn = new SqlConnection(connString))
      using (SqlCommand cmd = new SqlCommand("sp1", conn))
      {
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue("@param1", param1);
          cmd.Connection.Open();
          using (SqlDataReader reader = cmd.ExecuteReader())
          {
              while (reader.Read())
              {
                  try
                  {
                      string hash= utils.SHA256.Hashing((string)reader["firstRow"], saltValue);
                      using (SqlConnection conn2 = new SqlConnection(connString))
                      using (SqlCommand cmd2 = new SqlCommand("sp2", conn2))
                      {
                          cmd2.CommandType = CommandType.StoredProcedure;
                          cmd2.Parameters.AddWithValue("@param1", param1);
                          cmd2.Parameters.AddWithValue("@param2", param2);
                          cmd2.Connection.Open();
                          cmd2.ExecuteNonQuery();
                      }
                  }
                  catch (SqlException ex)
                  {
                      //something
                  }
              }
          }
      }
  </code></pre>
  
  <p>but it throws an error:</p>
  
  <pre><code>[InvalidOperationException: Invalid attempt to call Read when reader is closed.]
  System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +640
  System.Data.SqlClient.SqlDataReader.Read() +9
  </code></pre>
  
  <p>In development environment it works fine, but here there's only a few hundred rows. It throws the error immediately, so it doesn't directly look like some kind of timeout, but hey - I don't know...</p>