If error in objConn.execute(sql) then respond

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]

	objrec.Update
	


     objConn.execute(sql)

Open in new window

JLohmanAsked:
Who is Participating?
 
Big MontyConnect With a Mentor Senior Web Developer / CEO of ExchangeTree.org Commented:
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]

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


     objConn.execute(sql)     '-- not quite sure what this line does, you already opened up the sql statement a few lines back
0
 
Ryan ChongCommented:
>>"WEB PAGE CANNOT DISPLAY"

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"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.