Prev: Visual Studio 2008 database project or just use SSMS?
Next: Need Assistance With Defining Column Value in a View
From: Andy B. on 25 Mar 2010 11:13 What is the best way to format an error when using raiserror? I need to be able to make it easy to unpack the error package on the client so it can get all info needed. Or is the SQLException good enough for catching sql errors on the client? This is with C#/VB 3.0.
From: Tom on 25 Mar 2010 13:10 On Mar 25, 11:13 am, "Andy B." <a_bo...(a)sbcglobal.net> wrote: > What is the best way to format an error when using raiserror? I need to be > able to make it easy to unpack the error package on the client so it can get > all info needed. Or is the SQLException good enough for catching sql errors > on the client? This is with C#/VB 3.0. While debugging something when you got an error what was missing? I like to include the values of all input parameters and any values computed prior to the error. TRY CATCH makes this quite simple. There is also a number of CATCH functions whose return value I also include. In the CATCH block I declare a VARCHAR(MAX) and concatenate all these together and present them with raiserror. RAISERROR has a character limit so put the important things first.
From: Andy B. on 26 Mar 2010 00:45
"Tom" <tom.groszko(a)charter.net> wrote in message news:4c727b5f-3643-4740-9d45-729f8a0493ac(a)h18g2000yqo.googlegroups.com... On Mar 25, 11:13 am, "Andy B." <a_bo...(a)sbcglobal.net> wrote: > What is the best way to format an error when using raiserror? I need to be > able to make it easy to unpack the error package on the client so it can > get > all info needed. Or is the SQLException good enough for catching sql > errors > on the client? This is with C#/VB 3.0. While debugging something when you got an error what was missing? I like to include the values of all input parameters and any values computed prior to the error. TRY CATCH makes this quite simple. There is also a number of CATCH functions whose return value I also include. In the CATCH block I declare a VARCHAR(MAX) and concatenate all these together and present them with raiserror. RAISERROR has a character limit so put the important things first. OK. Now, how would you format that? xml, delimited by ;? or comma? or |? That way the client app can have access to all of the parts to the error and not just the huge string. I.E. parse the string somehow. |