This topic is locked
[SOLVED]

 AND Condition

10/27/2010 9:32:20 AM
ASPRunnerPro General questions
J
Jay123 author

Hi!
I am using ASP Runner 6.1.
I have a code below (in Add Page Before Record Added) that will check 2 values and display an alert if the 2 conditions are met.

==========================================================================

dim rsExists, rsExists1

set rsExists = dal.Table1.Query("EmailAddress='" & values("EmailAddress") & "'","")

set rsExists1 = dal.Table1.Query("Course='" & values("Course") & "'","")

if not rsExists.eof And not rsExists1.eof then

Flush_output

Response.Write "<script>alert('Our record shows that you have registered to this course already.')</script>"

else

BeforeAdd=true

end if

rsExists.Close : set rsExists = Nothing

rsExists1.Close : set rsExists1 = Nothing

==========================================================================
I did some tests and the result was inconsistent. There were times that the alert pops up even if you register for a different course.
Thanks,

Jay

Sergey Kornilov admin 10/27/2010

You need to check for two conditions together.

set rsExists = dal.Table1.Query("EmailAddress='" & values("EmailAddress") & "' and Course='" & values("Course") & "'","")

if not rsExists.eof then

Flush_output

Response.Write "<script>alert('Our record shows that you have registered to this course already.')</script>"

BeforeAdd=False

else

BeforeAdd=true

end if

rsExists.Close : set rsExists = Nothing
J
Jay123 author 10/28/2010

Thanks, Sergey. It worked!