我在处理更新操作的视图上有一个触发器。当我使用MS Management Studio并进行插入时,我收到此错误:
Msg 50000, Level 16, State 10, Procedure Trigger_TempTableAttr_Lot_UpdateDelete, Line 166
Violation of UNIQUE KEY constraint 'UK_Lot_LotAccountCode'. Cannot insert duplicate key in object 'app.Lot'.
Msg 3616, Level 16, State 1, Line 1
An error was raised during trigger execution. The batch has been aborted and the user transaction, if any, has been rolled back.
这就是我触发的内容:
BEGIN TRY
EXEC(@UpdateSQL)
END TRY
BEGIN CATCH
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();
RAISERROR (@ErrorMessage, -- Message text.
16, -- Severity.
10 -- State.
);
RETURN
END CATCH
CREATE TRIGGER[dbo].[Trigger_TempTableAttr_Lot_UpdateDelete] ON [dbo].[TempTableAttr_Lot]
INSTEAD OF UPDATE, INSERT, DELETE
AS
BEGIN
从此开始的错误永远不会发送到DataAdapter,它会无声地失败。我在DataAdapter.RowUpdated上有一个事件处理程序,但此操作没有错误。 INSERT或DELETE也没有捕获错误。
可能会阻止我在应用程序中收到错误?