Click to See Complete Forum and Search --> : check if value already exist


gerjan
06-26-2003, 07:16 AM
Check if value already exist.

I’ve written a script for a newsletter.
Works fine, except some visitors subscribe themselves more than one’s.
I can prevent that to check if a field already contains a value.
I thought I put a check before the e-mail will be added.
But somehow I get errors when I add two times a sql statement in my code.

Could somebody explain me how to do this?
I put the code (without the check, because it don’t work) as an attachment.

'THIS IS THE CODE I TRIED TO PUT BEFORE INSERT STATEMENT, BUT GENERATES AN ERROR (somehow because I have 2 statements?)!
sqstringcheck = "SELECT * FROM nieuwsbrief WHERE email = '"&email&"'"
set objRScheck = objConn.execute (sqstringcheck)
set emailcheck = objRScheck("email")

if emailcheck <> "" then
response.redirect "../../nieuwsbrief.asp?fout=exist"
end if

sqstringcheck.close
set sqstringcheck = nothing

simflex
06-26-2003, 07:40 AM
the only thing I can say for you to try will be this:


sqstringcheck = "SELECT * FROM nieuwsbrief WHERE email = '"&email&"'"
set objRScheck = objConn.execute (sqstringcheck)

If Not objRScheck .Eof then
emailcheck = objRScheck ("email")
end if

if emailcheck <> "" then
response.redirect "../../nieuwsbrief.asp?fout=exist"
end if

sqstringcheck.close
set sqstringcheck = nothing

gerjan
06-26-2003, 08:26 AM
Tnx for the note, I probably looked over it!
But I added the code below and still get
error '80020009'
Exception occurred.
/site/admin/nieuwsbrief/bedankt.asp, line 42

--- CODE ADDED, SEE THE FILE ATTACHED ---
'XXXX
sqstringcheck = "SELECT * FROM nieuwsbrief WHERE email = '"&email&"'"
set objRScheck = objConn.execute (sqstringcheck)
set emailcheck = objRScheck("email")

if emailcheck <> "" then
response.redirect "../../nieuwsbrief.asp?fout=exist"
end if

objRScheck.close
set objRScheck = nothing
'XXXX

gerjan
06-27-2003, 03:42 AM
problem solved!

Sorry, didn't know that whe I save an ASP file as a TXT file, it typed out the full included files.

this is line 42:
if emailcheck <> "" then

But I already found out what the problem was (Dave learned me at my post before).
I was forgotten this:

If IsNull(objRScheck("email").Value) Then
emailcheck = ""
Else
emailcheck = objRScheck("email").Value
End If

Whit these files it workes out fine!
So, tnx Dave :)