If error in objConn.execute(sql) then respond

Posted on 2011-05-10
Medium Priority
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 54

Expert Comment

by:Ryan Chong
ID: 35735400

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 34

Accepted Solution

Big Monty earned 2000 total points
ID: 35737487
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

839 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