Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server - report error back to .NET

I'm using Entity Framework with stored procedures for inserting/updating/deleting entities.

The task that I'm doing is inventory management with FIFO/LIFO methods => those inserts/updates/deletes perform several checks and can fail (sometimes they fail).

The problem is I want to report back to .NET what went wrong and why. How can I do it?

Currently I'm using something like this:

BEGIN --rollback
ROLLBACK TRAN
RAISERROR (N'There''s not enough items in stock.', -- message
    16, -- severity
    1) -- state
END;

I always get "MSDTC error" - "The underlying provider failed on EnlistTransaction."

like image 479
kubal5003 Avatar asked Nov 14 '22 11:11

kubal5003


1 Answers

I don't think it is getting that far. It is erroring out when one of the transactions is starting up, your custom error is not getting raised.

like image 182
King Avatar answered Dec 24 '22 13:12

King