Newbie question on error checking

Discussion in 'ASP General' started by rich, Jan 30, 2006.

  1. rich

    rich Guest

    Hello,

    I am fairly new to ASP code and need help with error checking within my
    script.

    Specifically, I need to check for 3 things:

    1. Trap the error if the script cannot find or connect to Active Directory.
    2. Trap the error if the script cannot find the requested FSM Group.
    3. Trap the error if the required input file is missing or it cannot create
    or edit the output file.

    I have learned a little about using the Err Object (Err.number and
    Err.description) but that is about it. Can anyone offer me any general
    tips/tricks about how best to do this or point me to some good reference
    material?

    Thanks in advance,

    Rich
     
    rich, Jan 30, 2006
    #1
    1. Advertising

  2. rich

    Chi Guest

    When you make connections to Database its good practice to put them all
    within a try / catch statement as follows...

    Try
    'Open connection and perform what you need don
    Catch ex As Exception
    'Write code here to catch any errors and perform anything
    that you want to perform if the code hits an error.
    (example...)
    Dim strError as string = ex.Message 'This will write
    the error to the strError
    End Try

    Dont forget to close connections. Look at MSDN for Try/Catch Statements if
    you need further info. But I believe its the Try/Catch is what you are
    looking for.


    "rich" <> wrote in message
    news:...
    > Hello,
    >
    > I am fairly new to ASP code and need help with error checking within my
    > script.
    >
    > Specifically, I need to check for 3 things:
    >
    > 1. Trap the error if the script cannot find or connect to Active
    > Directory.
    > 2. Trap the error if the script cannot find the requested FSM Group.
    > 3. Trap the error if the required input file is missing or it cannot
    > create
    > or edit the output file.
    >
    > I have learned a little about using the Err Object (Err.number and
    > Err.description) but that is about it. Can anyone offer me any general
    > tips/tricks about how best to do this or point me to some good reference
    > material?
    >
    > Thanks in advance,
    >
    > Rich
     
    Chi, Feb 1, 2006
    #2
    1. Advertising

  3. This user is likely using vbscript in a .asp page, not VB.Net in a .aspx
    page, given that he posted in a classic asp group and mentioned the vbscript
    Err object.
    Chi wrote:
    > When you make connections to Database its good practice to put them
    > all within a try / catch statement as follows...
    >
    > Try
    > 'Open connection and perform what you need don
    > Catch ex As Exception
    > 'Write code here to catch any errors and perform
    > anything that you want to perform if the code hits an error.
    > (example...)
    > Dim strError as string = ex.Message 'This will
    > write the error to the strError
    > End Try
    >

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Feb 1, 2006
    #3
  4. rich wrote:
    > Hello,
    >
    > I am fairly new to ASP code and need help with error checking within
    > my script.
    >
    > Specifically, I need to check for 3 things:
    >
    > 1. Trap the error if the script cannot find or connect to Active
    > Directory.
    > 2. Trap the error if the script cannot find the requested FSM Group.
    > 3. Trap the error if the required input file is missing or it cannot
    > create or edit the output file.
    >
    > I have learned a little about using the Err Object (Err.number and
    > Err.description) but that is about it. Can anyone offer me any
    > general tips/tricks about how best to do this or point me to some
    > good reference material?
    >

    I somehow missed this question the first time around. Are you still here?

    Actually, what you've learned is pretty much all there is for error-handling
    in vbscript:

    'turn on error-handling
    on error resume next
    'do something whose error you wish to trap
    if err <> 0 then
    'handle the error
    end if
    'turn off error-handling
    on error goto 0

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Feb 1, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Rawson
    Replies:
    7
    Views:
    350
    Michele Simionato
    Aug 6, 2003
  2. LDD

    Newbie : checking semantics

    LDD, May 7, 2005, in forum: Python
    Replies:
    25
    Views:
    663
    Antoon Pardon
    May 17, 2005
  3. Thomas Luedeke
    Replies:
    1
    Views:
    81
    Gregory Brown
    Jul 30, 2008
  4. Gnarly
    Replies:
    1
    Views:
    77
    Laurent Bugnion, GalaSoft
    Sep 9, 2003
  5. Jerry C.
    Replies:
    8
    Views:
    250
    Uri Guttman
    Nov 23, 2003
Loading...

Share This Page