title: OleDb multiple connection in a loop
body: <p>I try to do a multiple connection with Oledb, in order to decrement my variable in my SQL request.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
  
      int var = 0;
      string conn = " ... ";
      OleDbConnection connexion = new OleDbConnection(conn);
      connexion.Open();
  
      OleDbCommand cmd = new OleDbCommand("SELECT ID, DATA_1, DATA_2 from Database WHERE ID = ( SELECT MAX (ID) -" + var + " FROM Database);", connexion);
      OleDbDataReader reader = cmd.ExecuteReader();
      reader.Read();
  
              if (!reader.HasRows)
              {
                  while (!reader.HasRows)
                  {
                      OleDbConnection connexion2 = new OleDbConnection(conn);
                      connexion2.Open();
  
                      var++;
                      OleDbCommand cmd2 = new OleDbCommand(""SELECT ID, DATA_1, DATA_2 from Database WHERE ID = ( SELECT MAX (ID) -" + var + " FROM Database);", connexion2);
                      OleDbDataReader reader2 = cmd2.ExecuteReader();
                      reader2.Read();
  
  
                      reader = reader2;
                      reader2.Close();
                      connexion2.Close();
  
                  }
              }
              else
              {
                  Label5.Text = "Line Empty";
              }
  
  
          }
  
  
  
  
      reader.Close();
      connexion.Close();
  </code></pre>
  
  <p>}</p>
  
  <p>I have an error Line 76 : </p>
  
  <blockquote>
    <p>Attempt to call HasRows Invalid When the driver is close.</p>
  </blockquote>
  
  <p>Ligne 74 :                 if (!reader.HasRows)</p>
  
  <p>Ligne 75 :                 {</p>
  
  <p><strong>Ligne 76 :                     while (!reader.HasRows)</strong>     ERROR</p>
  
  <p>Ligne 77 :                     {</p>
  
  <p>Ligne 78 :                         OleDbConnection connexion2 = new OleDbConnection(conn);</p>