PC Review


Reply
Thread Tools Rate Thread

How to get all result sets and all error messages from MS SQL 2000?

 
 
Apokrif
Guest
Posts: n/a
 
      26th Aug 2003
There is a stored procedure with following code:

....
RAISERROR 30000 'xxxx'
SELECT 1 as F1
RAISERROR 30000 'zzzz'
....

In C# I have something like that:
.....
string _exceptionMessage = "";
SqlCommand cmd = new SqlCommand(sql,conn);
try
{
SqlDataReader rdr = cmd.ExecuteReader();
do
{
while(rdr.Read())
{
//do something
....
}
}
while(rdr.NextResult());
}
catch(SqlException e)
{
for(int j=0;j<e.Errors.Count;j++)
{
_exceptionMessage += e.Errors[j].Number.ToString()+" -
"+e.Errors[j].Message+"\r\n";
}
}
.....
So I want to get two error messages and one result set.
But I got exception in ExecuteReader() so I didn't get access to
DataReader. And I don't understand how to get everything from sql
server.
Even I can't get all error messages because within catch I always have
e.Errors.Count equal 1.

When I run my stored procedure in QueryAnalyzer I have no problem.
I can see everything as output:

Server: Msg 30000, Level 16, State 1, Procedure CompanyGetInfo, Line
31
xxxx
F1
-----------
1
(1 row(s) affected)
Server: Msg 30000, Level 16, State 1, Procedure CompanyGetInfo, Line
33
zzzz

Any help will be appreciated.

In the best we trust
George Nevsky
 
Reply With Quote
 
 
 
 
Apokrif
Guest
Posts: n/a
 
      26th Aug 2003
>Unless the severity is 10 or higher, the exception
handler won't kick in.
>You need to add a InfoMessage event handler to your code

to trap the message
>sent back from RAISERROR.


Yes, I found OnInfoMessage event but I never get that
message if raiserror with severity > 10 happened before
exception with severity <10.
I.e. I can't get info message from following T-SQL code:
RAISERROR('error',16,1)
RAISERROR('info',10,1)

 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      26th Aug 2003
That's because high sev errors are passed back to ADO.NET and it gives up on
trying to process more data from the TDS stream.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Apokrif" <(E-Mail Removed)> wrote in message
news:009201c36bff$fd3f1c30$(E-Mail Removed)...
> >Unless the severity is 10 or higher, the exception

> handler won't kick in.
> >You need to add a InfoMessage event handler to your code

> to trap the message
> >sent back from RAISERROR.

>
> Yes, I found OnInfoMessage event but I never get that
> message if raiserror with severity > 10 happened before
> exception with severity <10.
> I.e. I can't get info message from following T-SQL code:
> RAISERROR('error',16,1)
> RAISERROR('info',10,1)
>



 
Reply With Quote
 
Apokrif
Guest
Posts: n/a
 
      27th Aug 2003
> From: "Apokrif" <(E-Mail Removed)>

Nice nickname.
--
« L'objet propre de la philosophie est l'étude systématique
des notions confuses » PERELMAN
_________________________________________________________________________
Le meilleur dictionnaire français en ligne: http://atilf.atilf.fr/tlf.htm
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Multiple result sets Sahil Malik Microsoft ADO .NET 0 7th Mar 2005 08:50 PM
One Sql Command, Two Result Sets Michael C# Microsoft C# .NET 3 7th Mar 2005 07:38 AM
Re: Empty result sets MGFoster Microsoft Access Queries 0 18th Aug 2004 09:20 PM
Re: Multiple result sets Kathleen Dollard Microsoft ADO .NET 0 14th Jul 2003 04:27 PM
Re: Multiple result sets Joe Fallon Microsoft ADO .NET 0 12th Jul 2003 08:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:19 PM.