error that occur in StoredProcedure it's throw exception to Ado.net?

  • Thread starter Thread starter mttc
  • Start date Start date
M

mttc

I ask it before and I got this answer:

======================================================
yes errors with a certain severity level will throw exceptions in your
code

try this in your stored proc


RAISEERROR(N'This is a message %s %d', -- message text
16, --severity
1, --state
N'number', --first argument
5); --second argument


and in your code you can get this error message in the SqlException
object
--
Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin
=======================================================

I have to ask more:
the built-in errors have high level for breack the SP and throw it
to .NET?
if have, How I trap this error in SP to rollback my transaction or do
somthing else within the SP instead thorow it immediately to .NET?
 
begin try
<your code>
end try
begin catch
<your code>
end catch

No CLR activation needed, it's pure TSQL in sql server 2005.
It will catch many exceptions, but not all.
Look up the documentation.
 
Back
Top