ASP: VBScript condition evaluation checks every condition even if one already is false!
Posted on 2003-11-25
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):
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"
Even once oRs reaches EOF it attempts to evaluate the check if oRs("some_field") = "some value" and the entire asp dies saying:
/some/script.asp, line 316
Line 316 is the 'Do While...' line.