Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping User-Defined Errors from SQL Server in VB 6.0

Status
Not open for further replies.

UncleT

Programmer
Joined
Sep 26, 2001
Messages
133
Location
US
Hello,

I am fairly new to the world of programming in VB using SQL Server. I recently took a class in SQL Server and the teacher explained how the user can create user-defined error messages in SQL Server starting at 50001. I have been playing around with this and I can't understand how to trap that error in VB. For example I created a stored procedure that uses the RAISEERROR. I use 10 as the severity level. When I execute the stored procedure in VB I do not get the error message. If I up the severity level to 16 VB errorhandling will take over and my error routine will display the message. The question I have is: I set the error message in SQL to severity level 11 or above so that VB will reconize the error, how can I tell that it is a user-defined error and not a severe SQL error. I need to know this so I will know to just display a message for the user or display the message and then crash the application.

Thanks in advance,

UncleT
 
You may want to investigate the Errors collection of the ADODB object
 
Thanks strongm I didn't think to look there. I found exactly what I need.

One more question. How do you get VB to reconize a user-defined error from SQL if the severity is set to 10. It don't seem to register that in the ADODB object?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top