uhu
uhu

Reputation: 1742

Catch an exception of an asynchronous called SQL-Server stored procedure

I call asynchrounously some stored procedures with BeginExecuteNonQuery and EndExecuteNonQuery (in C#). How can I catch the (defined) exceptions of these stored procedures in the C# program? Or does the try{}catch{} also works for asynchrounous calls?

Upvotes: 0

Views: 196

Answers (3)

Remus Rusanu
Remus Rusanu

Reputation: 294247

Any exception with severity above 10 raised in the procedure execution that was returned to the client (ie. not swallowed by BEGIN TRY/BEGIN CATCH) will be raised as a SqlException in the moment you invoke EndExecuteNonQuery.

Upvotes: 1

Wes Price
Wes Price

Reputation: 346

Not too sure if this will help but i've used this method to catch SP exceptions from C# before

http://www.java2s.com/Tutorial/CSharp/0560__ADO.Net/Catchexceptionwhencallingstoredprocedure.htm

Upvotes: 0

Adam Houldsworth
Adam Houldsworth

Reputation: 64487

Any errors raised during a stored procedure will surface in .NET as a SqlException with an error number.

Upvotes: 0

Related Questions