PDA

View Full Version : How to make a transactional script


codefox
12-01-2002, 08:32 AM
I have a feedback form with several items. Each item has a rating and a remark. On submitting the form, an asp script inserts all items into a table. I've to ensure that either all feedback items are inserted into the table or none. So I decided to make the script a transactional one. Now if there's a runtime error after inserting few records IIS redirects the page to 500-100.asp. How do I trap the runtime error, do ObjectContext.SetAbort and then redirect the page to 500-100.asp? I know that "On Error" statement can be used to trap runtime errors, but I don't know how to proceed.

Mhtml
12-01-2002, 08:43 AM
www.w3schools.com/asp

Have a look at the error object

codefox
12-01-2002, 09:11 AM
Thanks. Actually just adding @Transaction="Required" as the first line in the script made the script transactional and if a runtime error occurs, the transaction is aborted automatically. I thought I'd to explicitly code ObjectContext.SetAbort by trapping the runtime error. Without the @Transaction statement the records that were inserted before the runtime error occured still reside in the db. Giving the @transaction statement automatically removes the inserted records when a runtime error occurs. That's cool :).