Advertisement

08.14.2008 at 10:04AM PDT, ID: 23648885
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

How can I get my On Error Resume Next to process my error routine?

Asked by dyarosh in VB Script

Tags:

I have a website developed using ASP and VBScript.  I have 2 ASP files: services.asp and functions.asp.  I have an On Error Resume Next statement in functions.asp.  I put an error in my connection string to test the On Error Functionality but it does not behave as I expected.  The error generates at the myConnection.Open ConnStr statement but the HandleADOError is never called.  I put Response.Write statements in and those that appear before the open statement are printed but those after the Open statement within the OpenDatabase function do not.  (I commented out the call to the HandleADOError function and replaced it with a Response.Write statement which is never written.)  The function returns false so my "Error found" message is written.  Can't figure out what I'm doing wrong.  Any help would be greatly appreciated.

Services.asp calls functions defined in functions.asp.  Services.asp has the following at the top of its page:

<!-- #include file="functions.asp" -->
<%
      ' Open connection to database
      if NOT OpenDatabase() then
            Response.Write "Error found"
            'Response.Redirect "error.asp"
      end if
%>

Functions.asp is defined as follows:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Option Explicit
Dim myMail, myConnection, rsCareType

On Error Resume Next

function OpenDatabase()

      Dim ConnString
      
      Set myConnection = Server.CreateObject("ADODB.Connection")
      if err.number <> 0 then
            OpenDatabase = false
      else
            myConnection.Errors.Clear()
            
            'define the connection string, specify database driver
            ConnString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=myserver.com; " &_
                   "PORT=3306; DATABASE=dbname; UID=userid;PASSWORD=password; OPTION=3"
            myConnection.Open ConnString
            if myConnection.Errors.Count > 0 then
                  Call HandleADOError()
                  OpenDatabase = false
            else
                  OpenDatabase = true
            end if
      end if
end function

sub HandleADOError()

      Dim objErr, errMsg
      errMsg = ""
      for each objErr in myConnection.Errors
            errMsg = errMsg & "<p>"
             errMsg = errMsg & "Description: "
            errMsg = errMsg & objErr.Description & "<br />"
            errMsg = errMsg & "Help context: "
            errMsg = errMsg & objErr.HelpContext & "<br />"
            errMsg = errMsg & "Help file: "
            errMsg = errMsg & objErr.HelpFile & "<br />"
            errMsg = errMsg & "Native error: "
            errMsg = errMsg & objErr.NativeError & "<br />"
            errMsg = errMsg & "Error number: "
            errMsg = errMsg & objErr.Number & "<br />"
            errMsg = errMsg & "Error source: "
            errMsg = errMsg & objErr.Source & "<br />"
            errMsg = errMsg & "SQL state: "
            errMsg = errMsg & objErr.SQLState & "<br />"
            errMsg = errMsg & "</p>"
      next
      Call SendMail("email@mydomain.org", "email@mydomain.org", "", "ADO Error", errMsg)
end sub
Start Free Trial
[+][-]08.14.2008 at 10:15AM PDT, ID: 22232171

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Script
Tags: VBScript
Sign Up Now!
Solution Provided By: purplepomegranite
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628