Thank You.
I have intentionally included a failed insert statement and then tried to catch the raiseerror message from asp.net application per your instructions.
When I execute the code , it is throwing SQL system message as
Cannot insert the value NULL into column 'Comments', table 'GisClient.dbo.TestError'; column does not allow nulls. INSERT fails. The statement has been terminated.
Looks like it is not checking next statements when INSERT command is failed .. I have written something like this in proc.
CREATE PROCEDURE usp_MyErrorProc
AS
BEGIN
Declare @t_ErrorNo int
Declare @t_ErrorDesc Varchar(250)
SET NOCOUNT ON
INSERT INTO TESTERROR (Message) Values ('Hello ..This is a test ')
SET @t_ErrorNo =@@ERROR
if @t_Errorno<>0 begin
SET @t_ErrorDesc=' Error Generated while executing INSERT statement'
GOTO ErrHand
end
--------------****************************** ERROR HANDLER ******************************************
ErrHand:
IF @@ERROR <> 0
BEGIN
-- Rollback the transaction
ROLLBACK TRANSACTION
-- Raise an error and return
RAISERROR (@t_ErrorDesc, 16, 1)
RETURN
END
END
GO