title: CLASSIC ASP - Do While / Loop with 3 conditions issue
body: <p>I Have a SELECT with:</p>
  
  <p>STATUS -1, 0 and 1.</p>
  
  <p>The SELECT Statment:</p>
  
  <pre><code>SQL= "SELECT * FROM MYTABLE ORDER BY STATUS DESC" 
  SET MYDB = conn.Execute(SQL)
  </code></pre>
  
  <p>My issue:</p>
  
  <p>Divide the SELECT in two parts with DO WHiLE/LOOP</p>
  
  <p>PART 1:</p>
  
  <ul>
  <li>"NOT EOF" of course</li>
  <li>ALL STATUS 1 (priority and overule register limit)</li>
  <li>Limit to XX registers (variable - TOTALREG)</li>
  <li>NO STATUS -1</li>
  </ul>
  
  <p>** STATUS 1 is the "Approved" status and can overrule the limit of registers. </p>
  
  <p>I have a classroom with 20 students. (limit of registers)
  but I can overbook this and make the class with 21, 22, 23 students - with "STATUS 1" = approved. </p>
  
  <p>If I have only 15 approved - I will complete the limit of registers with the first 5 "STATUS 0" (Waiting for approval).</p>
  
  <p>PART 2:</p>
  
  <ul>
  <li>the rest of the SELECT </li>
  </ul>
  
  <p>I Got a PARTIAL solution with this:</p>
  
  <pre><code>DO WHILE (((NOT MYDB.EOF) AND (CINT(COUNTREG) &lt;= CINT(TOTALREG))) OR ((NOT MYDB.EOF) AND (MYDB("STATUS") &gt; 0 ))) AND ((NOT MYDB.EOF) AND (MYDB("STATUS") &gt; -1 ))    
  </code></pre>
  
  <ul>
  <li>IF we have vacancies: <code>(NOT MYDB.EOF) AND (CINT(COUNTREG) &lt;= CINT(TOTALREG))</code></li>
  <li>IF the register is approved: <code>(NOT MYDB.EOF) AND (MYDB("STATUS") &gt; 0 )</code></li>
  <li>Exclude non-approved registers (status -1): <code>(NOT MYDB.EOF) AND (MYDB("STATUS") &gt; -1 )</code></li>
  </ul>
  
  <p><br><br><br>
   - COUNTREG = will be incremented for each register inside the LOOP (countreg = countreg + 1)<br>
   - TOTALREG = Is a variable (number of person allowed in the classroom) </p>
  
  <p>Its works with all situation.. but when I don't have registers with STATUS = -1  - I got an error '80020009'</p>
  
  <p>why? any idea?</p>