sql server - Do while loop on recordset keeps running while the total records are way less -


io got real weird problem in asp classic page. generating schedule of days off employees. when tested it seemed work fine. though option go week , forth , when went 3 weeks loop keeps getting looping on 1 single record.

so wanted check problem doing count on recordset after sql execution.

for reason though, while loop keeps looping. did print count in while see how many records finds , on 508 000 !

so in t-sql server (2012) did exact same query , here results in 953 records...

so tghere goes wrong in loop.

here code using:

strsql = "select * [qrysnipperkalender_b] [snipperdag] >= "& szstart &" , [snipperdag]<= "& szend &" order [functiegroep], [relatienaam], [datum] asc"       response.write(strsql & "<br> <br>")      set rst=con_sql.execute(strsql)     countcheck = 0       until rst.eof or rst.bof         response.write("count is: " & countcheck & "<br>")          countcheck = countcheck + 1     loop      response.write("rst count      :" & countcheck)     response.end 

the response.end , response.write rst count never hit, keeps looping making page slow.

the response.write sql results in: select * [qrysnipperkalender_b] [snipperdag] >= 15281 , [snipperdag]<= 15355 order [functiegroep], [relatienaam], [datum] asc

when run query in sql server results in 953 records (like should).

so question is, why loop broken / keeps running?

i tried modify loop rst.bof (first had eof) doesn't have effect. tried use if condition inside loop if hits eof exit loop, doesn't work.

you forgot rst.movenext within loop navigate next record

do while not rst.eof      countcheck = countcheck + 1     response.write("count is: " & countcheck & "<br>")     rst.movenext loop 

Comments