Instead of [if objRS.EOF] try [if not objRS.EOF]? The EOF property of
the recordset will be true if your select statement brings back no
records - i.e. the log doesn't already exist in your database.
 
Dan
 
________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 21 June 2005 12:24
To: [email protected]
Subject: [AspClassicAnyQuestionIsOk] trying to find out if record
already exists


Hi Guys

I am trying to stop the users from resubmiting the same log into the
database so to do this I am using a select statement to find out if the
record already exists, if it does then I need to display an error
message and stop it from inserting into the DB, if it does not exist
then I need to do the update.  The update seems to be working fine but
the code does not seem to be stopping the update if the record already
exists?

Can somebody tell me where I am going wrong?

This is my code:

strSQL = "SELECT * FROM tblevent WHERE strDate='" & strDate & "' AND
strTime='" & strTime & "' AND strReceivedvia='" & strReceivedvia & "'
AND strReceivedfrom='" & strReceivedFrom & "' AND strCustomerType='" &
strCustomerType & "' AND strDetails='" & strDetails & "' AND
AUTH_USER='" & AUTH_USER & "'"
      
      set objRS = Server.CreateObject ("ADODB.Recordset")
      objRS.Open "tblevent", objConnection,,adLockOptimistic,adCmdTable
      IF objRS.EOF Then
            response.write "That entry already exists in the database" &
vbcrlf
      Else
            'Set objRS = Server.CreateObject ("ADODB.Recordset")
            'objRS.Open "tblevent",
objConnection,,adLockOptimistic,adCmdTable
            objRS.AddNew
            objRS("strDate") = Request.Form("Date")
            objRS("strTime") = Request.Form("Month")
            objRS("strDate") = strMonth & "/" & strDay & "/2005"
            objRS("strTime") = strHour & ":" & strMinute
            objRS("strReceivedvia") = Request.Form("receivedvia")
            objRS("strReceivedfrom") = Request.Form("receivedfrom")
            objRS("strCustomerType") = Request.Form("CustomerType")
            objRS("strDetails") = Request.Form("details")
            objRS("AUTH_USER") = Request.ServerVariables("AUTH_USER")
            objRS.Update
            objRS.Close
            Set objRS = Nothing
            objConnection.Close
            set objConnection = Nothing
            
            response.write" <p class=""text"">Your record has been
saved, please click </p>" & vbcrlf
      End If       



________________________________

Yahoo! Groups Links


*       To visit your group on the web, go to:
        http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
          
*       To unsubscribe from this group, send an email to:
        [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
subscribe> 
          
*       Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 




[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

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

<*> 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