What database are you using, and what data type is the OverWrite field? If it's access 
and the data type is Yes/No (good old access), then the field will hold True / False 
and you should be checking to see if objRS("Overwrite") = true. If it's a text 
(access) or char / varchar etc (SQL server) field then check the case of the "Yes" 
string so make sure it's consistent with your code. The code looks fine in itself, so 
I'd guess it's a discrepancy between the data in the field, and the condition you're 
checking for.

Dan
www.diado.com

-----Original Message-----
From: professorw999 [mailto:[EMAIL PROTECTED]
Sent: 13 September 2004 23:40
To: [EMAIL PROTECTED]
Subject: [ASP] Problem Updating Database Record


I realize this is a little quirky, but here goes.  I have a basic 
script that searches my database table for the users email address.  
IF the record does not exist THEN insert a new record.  ELSE display 
the "email already exists" message.  However, I need to throw in one 
kink.  If the record already exists, but the Overwrite field 
= "Yes", the record should be updated.

Below is the base of my script.  If the record is found, it keeps 
displaying the "email already exists" message.  I can't seem to get 
the excemption to work based on the Overwrite field.  Does someone 
see what I am missing?

mySQL = "SELECT * FROM tblProfiles WHERE fEmail = '" & strEmail & "'"
objRS...
objConn...

IF objRS.EOF THEN
objRS.AddNew
...
objRS.Update

ELSEIF objRS("Overwrite") = "Yes" THEN
objRS.MoveFirst
...
objRS.Update

ELSE
Response.Write "Your email already exists in our database."

END IF

Thanks,
PW




---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links



 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to