Showing posts with label neti. Show all posts
Showing posts with label neti. Show all posts

Friday, February 24, 2012

Handle SQL errors with severity 10

how to handle sql errors with severity less then 10 in .NET

i call to stored procedure which raise error with severity 10 for example
however in c# i can't cach this error (with severiry >= 11 it going to the
catch block in my c# app), also the @.@.ERROR is equal to zero when severity
<= 10

--
Message posted via http://www.sqlmonster.comE B via SQLMonster.com (forum@.SQLMonster.com) writes:
> how to handle sql errors with severity less then 10 in .NET
> i call to stored procedure which raise error with severity 10 for example
> however in c# i can't cach this error (with severiry >= 11 it going to the
> catch block in my c# app), also the @.@.ERROR is equal to zero when severity
><= 10

You set up an InfoMessages event handler. Please see the .Net Framework
reference for details.

In SqlClient 2.0, there is a new property which permits you divert all
errors with severity <= 16, that is all user errors, to the InfoMessage
handler. This actually has a couple of advantages, particulary when
you use ExecuteReader, so there is all reason to get used to InfoMessages.

By the way, a small tidbit: you can never get a message with severity
10 from SQL Server. 10 is always changed to level 0.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||ok i understand., Thank u in andvance.

Learning learning an learning

--
Message posted via http://www.sqlmonster.com