Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Catch Raiserror in ASP.NET

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2010-02-04 : 16:28:00
I used sp below to test transation.
In order to catch error in ASP.NET, I rename Order to Order2 but ASP.NET never catch an error. (I use try, catch Exception in ASP.NET)
How to catch Raiserror in ASP.NET?

BEGIN TRAN
BEGIN
INSERT INTO Order(orderno,createby)
VALUES ( @order,@createby)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error ',16,1)
RETURN
END
END
BEGIN
INSERT INTO Ship(orderno,createby)
VALUES ( @order,@createby)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error ',16,1)
RETURN
END
END
COMMIT TRAN
   

- Advertisement -