A
Apokrif
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
....
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