[dba-VB] VB.Net - Try/catch

Mike & Doris Manning mikedorism at verizon.net
Mon Sep 5 15:43:22 CDT 2005


Most of the exception types have a Number property that holds this
information.  If you are using the generic exception, then you need to look
at it's ToString property to find the exception type involved and add an
additional Catch to collect those errors.  I generally set my Try/Catch up
like so...

Try
	Do something
Catch Ex as SQLClient.SQLException
	Do something
Catch Ex as Exception
	Do something
Finally
	Do something
End Try

Doris Manning
mikedorism at verizon.net

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. Colby
Sent: Monday, September 05, 2005 3:39 PM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] VB.Net - Try/catch

Does the exception object have a numeric code that I can use in a test
inside the catch?  I am attempting to append data into a table and have a
unique index on one field.  Obviously if the insert (append) fails I want to
trap that specific condition and ignore it, i.e. I already have that data
and want to just reject it the next time.  In order to do this I need to
evaluate the exception object inside the catch.  I am finding the string
description of the error but not the numeric code equivalent.

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/


_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com






More information about the dba-VB mailing list