Results 1 to 2 of 2

Thread: Opening data and trap error

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Question Opening data and trap error

    I'm opening a database using

    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.CursorLocation="3"
    Conn.ConnectionTimeout=30
    Conn.Open "mp"

    which works fine, what I want to be able to do if there is any errors during this process to set a flag which then stops the rest of my page doing any database work.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898
    At the top of your code have on error resume next, then have a file with your error routines in and save it in a file in the include directory, then include it in all your asp pages. After each call to a database command (i.e. connect to database. read recordset) use the err object.

    So at the top of your asp page....
    <%@ Language=VBScript %>
    <%option explicit%>
    <%On Error Resume Next %>
    <!--#include virtual="/include/ErrorHandler.asp"-->

    Then in the code

    <%set conn = server.CreateObject("webisis.DBwebConnection") %>
    <%if Err.number <> 0 then%>
    <%TrapError Err.description%>
    <%end if%>

    Where TrapError is a sub in the errorhandler

    Then at the bottom after the </HTML>
    <%ProcessErrors%>

    Again ProcessErrors is a sub in the errorhandler

Posting Permissions

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



Click Here to Expand Forum to Full Width