H
Hugo Ferreira
Hi everyone,
I've got a huge problem here that I can't seem to be able to solve (hope
someone out there can give me an hand):
I've made a stored procedure that applies some actions, which can result in
an error. IF an error is produced (like a FK contraint), then it is logged
in a temporary table (i.e., #ERROR_TABLE) along with several other stuff I
need, and the execution continues. This stored procedure will be invoked
using an SqlDataReader. My logic is: if the DataReader returns any result,
then an error was produced; allowing me to react to the error inside my
application. If it doesn't return any rows, then all went ok.
Ok... So the problem here is: SqlDataReader is checking for errors generated
by the stored procedure invokation, and is throwing an exception. I can
catch this exception, but then I will not be able to access the resultset
with the temporary table I want to read. This temporary table contains vital
information about the error that I need to process. So I'm looking to one of
two things:
a) Either a way to tell SqlServer to don't report errors back to the client
(when executing a stored procedure) (XACT_ABORT OFF is not enough);
b) Or a way to tell SqlDataReader to DON'T THROW an exception, since there
is results in the resultset that I want to read!
Another way to get around the problem is to log the errors to a permanent
table. But the problem is that I'm inside a transaction, which will be
rollbacked if an error occurs. This rollback will affect the just inserted
row in the error-log table. If there is a way to issue a command inside a
stored procedure that is explicitly outside the current transaction, I would
be glad to know
Thanks in advance,
Hugo Ferreira
I've got a huge problem here that I can't seem to be able to solve (hope
someone out there can give me an hand):
I've made a stored procedure that applies some actions, which can result in
an error. IF an error is produced (like a FK contraint), then it is logged
in a temporary table (i.e., #ERROR_TABLE) along with several other stuff I
need, and the execution continues. This stored procedure will be invoked
using an SqlDataReader. My logic is: if the DataReader returns any result,
then an error was produced; allowing me to react to the error inside my
application. If it doesn't return any rows, then all went ok.
Ok... So the problem here is: SqlDataReader is checking for errors generated
by the stored procedure invokation, and is throwing an exception. I can
catch this exception, but then I will not be able to access the resultset
with the temporary table I want to read. This temporary table contains vital
information about the error that I need to process. So I'm looking to one of
two things:
a) Either a way to tell SqlServer to don't report errors back to the client
(when executing a stored procedure) (XACT_ABORT OFF is not enough);
b) Or a way to tell SqlDataReader to DON'T THROW an exception, since there
is results in the resultset that I want to read!
Another way to get around the problem is to log the errors to a permanent
table. But the problem is that I'm inside a transaction, which will be
rollbacked if an error occurs. This rollback will affect the just inserted
row in the error-log table. If there is a way to issue a command inside a
stored procedure that is explicitly outside the current transaction, I would
be glad to know
Thanks in advance,
Hugo Ferreira