Re: How to retrieve stored procedure error code in C#?
- From: "Mark Ashton" <markash@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 Aug 2005 17:15:19 -0700
By generating error codes, do you mean with the RAISEERROR or PRINT
statement?
You can listen to those with the SqlConnection.InfoMessage event.
SqlConnection connection = new SqlConnection(connectionstring);
connection.InfoMessage += new SqlInfoMessageEventHandler(InfoMessage);
connection.Open();
private static void InfoMessage(object sender, SqlInfoMessageEventArgs args)
{
foreach(SqlError arg in args.Errors) {
Response.Write("Number={0}, Message={1}", arg.Number, arg.Message);
}
}
--
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
"David Carr" <David_Carr@xxxxxxxxxxxxxxxx> wrote in message
news:%2379YZl5nFHA.3304@xxxxxxxxxxxxxxxxxxxxxxx
> Hi there,
>
> My SQL server 2000 stored procedures are generating different error codes.
> I am able to view these error codes when I run the stored proc in Query
> Analyzer. I am hoping to be able to obtain in my C# web service.
> Specifically, I am using SqlCommand and SqlDataReader objects for
> executing
> the stored procedure.
>
> Is there a simply mechanism/method to call to obtain the return code? I
> have seen some mention of the stored procedure having to stuff it into a
> parameter - I am hoping that I don't have to modify each of my stored
> procs
> to do that.
>
> Thanks in advance,
> David
>
>
.
- Follow-Ups:
- Re: How to retrieve stored procedure error code in C#?
- From: David Carr
- Re: How to retrieve stored procedure error code in C#?
- References:
- How to retrieve stored procedure error code in C#?
- From: David Carr
- How to retrieve stored procedure error code in C#?
- Prev by Date: Re: IDbConnection.CreateCommand Question
- Next by Date: Re: Weird dbconcurrency exception!
- Previous by thread: How to retrieve stored procedure error code in C#?
- Next by thread: Re: How to retrieve stored procedure error code in C#?
- Index(es):
Relevant Pages
|