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]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/