Link to home
Start Free TrialLog in
Avatar of robysath
robysath

asked on

ASP: VBScript condition evaluation checks every condition even if one already is false!

Why is it that in vbscript (in my asp page) the condition evaluation will check every single condition in the statement even tho it already found one that is false!?!?!?

This applies to "If" and "Do While" statements as far as I have seen.

How do I go about making it stop evaluating as soon as it arrives at a false statement.

Example (oConn is a connection to db that was established earlier):
Dim oRs
Set oRs = Server.CreateObject("ADODB.RECORDSET")
oRs.CursorLocation = 2 'use server supplied cursor
oRs.ActiveConnection = oConn

oRs.open("SELECT some_field FROM some_table")

Do While Not oRs.EOF And oRs("some_field") = "some value"
    ...
Loop

Even once oRs reaches EOF it attempts to evaluate the check if oRs("some_field") = "some value" and the entire asp dies saying:

Exception occurred.

/some/script.asp, line 316

Line 316 is the 'Do While...' line.
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

Do While Not oRs.EOF
if oRs("some_field") = "some value" then
Exit Do
end if
Loop
ASKER CERTIFIED SOLUTION
Avatar of Dexstar
Dexstar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robysath
robysath

ASKER

Points go to Dexstar for answering all questions, thanks.