This topic is locked

check if record exists

8/26/2009 11:38:02 PM
ASPRunnerPro General questions
G
guroos author

I have a simple form with 4 fields, one of which is 'email' based on table 'e2db'

The client requires if a user tries to fill out the form a second time instead of getting "record not added" etc.

that they get a custom error or redirect to another page.
From the help file I have tried modifying the following code, but I get errors:

dim rsExists

set rsExists = dal.e2db.Query("email=values('email')","")

if not rsExists.eof then

' if record exists do something

response.write "it exists"

else

' if dont exist do something else

response.write "doesnt exist"

end if

rsExists.Close : set rsExists = Nothing
BeforeAdd=true

J
Jane 8/27/2009

Please see my changes below:

flush_output

dim rsExists

set rsExists = dal.e2db.Query("email='" & values("email") & "'","")

if not rsExists.eof then

' if record exists do something

response.write "<script>alert('it exist');</script>"

Response.redirect "anotherpage.asp"

else

' if dont exist do something else

response.write "doesnt exist"

end if

rsExists.Close : set rsExists = Nothing