If error in objConn.execute(sql) then respond

Posted on 2011-05-10
Last Modified: 2012-05-11
I have an update form that is working correctly if users enter correct data. One field is a number field. If users attempt to enter text, the update page produces a "WEB PAGE CANNOT DISPLAY" page. Instead, I want to display a message that states:
"Record was not updated......"

dim sql, objRec, strCol, ChartID, item
ChartID = Request.form("ChartID")

sql = "SELECT * FROM tblStaff WHERE ChartID = " & ChartID
	Set objrec = Server.CreateObject("ADODB.Recordset")
	objrec.Open sql, objConn, adLockOptimistic, adCmdTable

	objrec("LibFTE") = Request.form("LibFTE")
         [all fields are identified]



Open in new window

Question by:JLohman
    LVL 48

    Expert Comment

    by:Ryan Chong

    It's because your script got error and make your page cannot be displayed.

    Pls do necessary debugging instead.

    1. If you're using IE browser, go to Menu Tools > Internet Options > Advanced Tab, make sure the "Show friendly HTTP error messages" is unchecked.

    2. For your ASP scripts, remark all "On Error Resume Next" that available and change it to "On Error Goto 0"
    LVL 32

    Accepted Solution

    he WANTS friendly error messages, so you would use "on error reseume next"

    dim sql, objRec, strCol, ChartID, item
    ChartID = Request.form("ChartID")

    on error resume next
    sql = "SELECT * FROM tblStaff WHERE ChartID = " & ChartID
          Set objrec = Server.CreateObject("ADODB.Recordset")
          objrec.Open sql, objConn, adLockOptimistic, adCmdTable

          objrec("LibFTE") = Request.form("LibFTE")
             [all fields are identified]

    if err.Number <> 0 then
       Response.Write "error updating record, please press your BACK button to correct."
    end if

         objConn.execute(sql)     '-- not quite sure what this line does, you already opened up the sql statement a few lines back

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now