Sign in to follow this  

Quick MSSQL 2005 Error Handling Question:

This topic is 3500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an ASP.NET application that executes stored procedures. In the case that a stored procedure throws any error whatsoever (even a non-fatal error), I want the program to grind to halt with a descriptive exception message being displayed in the Visual Studio debugger. For some reason, I've always used @@error, or try{} catch{} in my SQL code to mask the error and rollback the transaction. However, rolling back the transaction is almost always useless to me, because it often means a more severe and fatal error will inevitably occur later down the road whose cause was masked. If I don't provide any sort of error handling in my stored procedure code, will the SQL Client throw exceptions if anything bad happens? If it doesn't, can I get it to?

Share this post


Link to post
Share on other sites
I'm not 100% sure on this but I seem to remember from when I worked with some SQL databases that yes, your client will still throw exceptions in this situation. Is this what you want? I find working with databases a bit tricky when it comes to exceptions because if you don't do anything about an erroneous transaction it can lead to a corrupted database - bad times!

Have you not made a test client that chucks bad data at your database? Might be a good idea to make one.

James

Share this post


Link to post
Share on other sites

This topic is 3500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this