title: Id request from the database
body: <p>I'm trying to write the id request from the database. This is how I wrote it:</p>
  
  <pre><code>public int QueryId(String query)
      {
          var temp = this.connection;
          MySqlCommand verifica = new MySqlCommand(query, connection);
          var queryResult = verifica.ExecuteScalar();
          return Convert.ToInt32(verifica.ExecuteScalar());
      } 
  </code></pre>
  
  <p>This is how I make use of the function:</p>
  
  <pre><code>        MySqlDataReader reader = cmd.ExecuteReader();
          while (reader.Read())
          {
              nomeCorrente = reader.GetString("nome");
              cognomeCorrente = reader.GetString("cognome");
              idCorrente = db.QueryId("SELECT id FROM thewishlist.user WHERE email='" + user.Text + "'");
          }
  
          reader.Close();
          db.CloseConnection();
  </code></pre>
  
  <p>It does not generate errors, but when I run the project and log out the user gives me the following error:</p>
  
  <blockquote>
    <p><strong>MySql.Data.MySqlClient.MySqlException</strong> There is already an open DataReader associated with this Connection which must be closed first.</p>
  </blockquote>