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

Re: Newbie question on error checking by Chi

Chi
Wed Feb 01 12:03:56 CST 2006

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" <rich@discussions.microsoft.com> wrote in message
news:42116FAC-6283-46BD-B4B4-C091FA713D04@microsoft.com...
> 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



Re: Newbie question on error checking by Bob

Bob
Wed Feb 01 12:37:07 CST 2006

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.



Re: Newbie question on error checking by Bob

Bob
Wed Feb 01 12:39:54 CST 2006

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.