Error traping in form - Can someone please help???

Results 1 to 2 of 2

Thread: Error traping in form - Can someone please help???

  1. #1
    Join Date
    Dec 1969

    Default Error traping in form - Can someone please help???

    I hope that someone can please help me with this one - I&#039;m getting very frustrated & I&#039;m not sure where I&#039;m going wrong.<BR><BR>I have a form & when the user "adds" a new record, it&#039;s supposed to check to see if the Division already exists, if it does, it&#039;s supposed to pull open an alert box that states that it "Already Exists". If it does not already exist, then it should "add" the record. <BR><BR>It adds all records, even if they exist - but if you try to "add" it again (in the same session) it will bring up the box & tell you that it already exists.<BR><BR>Here&#039;s my code:<BR><BR>Dim DivisionID<BR><BR>DivisionID = Request("DivisionID")<BR><BR>&#039;Opens conneciton with database<BR>Set dbConn = Server.CreateObject("ADODB.Connection")<BR> dbConn.Open Session("ContactList_ConnectionString")<BR> <BR>&#039;Gets a recordset object to work with<BR>Set rsRecordSet = Server.CreateObject("ADODB.RecordSet")<BR> strSQL = "SELECT * FROM Divisions"<BR><BR>if Len(DivisionID) &#062; 0 then<BR> strSQL = strSQL & " WHERE DivisionID = " & DivisionID<BR>else<BR> &#039;bring up a blank record to add new to database<BR> strSQL = strSQL & " WHERE DivisionID = 0"<BR>end if<BR><BR>Set rsDivision = Server.CreateObject("ADODB.RecordSet")<BR> strSQLDivision = "SELECT * FROM Division"<BR><BR>if Len(Request.Form("_action")) &#062; 0 then<BR> Select Case Request.Form("_action")<BR> case "add","update" &#039;this handles either add or update button<BR> rsRecordSet.Open strSQL, dbConn,adOpenKeyset,adLockOptimistic<BR> Division_Name = Request("Division_Name")<BR> strSQLDivision = "SELECT * FROM Divisions WHERE Division_Name = &#039;" & Division_Name & "&#039;"<BR> Response.Write (strSQLDivision)<BR><BR> dbconn.Execute strSQLDivision<BR> <BR> if rsrecordset.EOF = false then<BR> call doDupFileAlert()<BR> <BR> sub doDupFileAlert()<BR> %&#062;<BR> &#060;SCRIPT LANGUAGE = javascript&#062;<BR> &#060;!--<BR> alert("This Division already Exists!")<BR> --&#062; <BR> &#060;/SCRIPT&#062;<BR> &#060;%<BR> end sub <BR> else<BR><BR> if Request.Form("_action") = "add" then<BR> rsRecordSet.AddNew<BR> <BR> rsRecordSet("Division_Name") = restoreNull(Request.Form("Division_Name"))<BR> rsRecordSet("Division_Address") = restoreNull(Request.Form("Division_Address"))<BR> rsRecordSet("Division_City") = restoreNull(Request.Form("Division_City"))<BR> rsRecordSet("Division_State") = restoreNull(Request.Form("Division_State"))<BR> rsRecordset("Division_Zip") = restoreNull(Request.Form("Division_Zip"))<BR> rsRecordset("Division_Country") = restoreNull(Request.Form("Division_Country"))<BR> <BR> <BR> rsRecordset("lastupdatedate") = Now()<BR> rsRecordSet.Update<BR> <BR> if Request.Form("_action") = "add" then<BR> &#039;moved it back outside the if statement<BR> DivisionID = getDivisionID()<BR> end if <BR> end if

  2. #2
    Join Date
    Dec 1969

    Default Confused between client and server..

    .. code.<BR><BR>Read the FAQs in the Nature of Things category on

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts