I have an application I am working on that will need the use of transactions. I am familiar with how they work, but need some suggestions on a current implementation. Here is the scenario...

A user is working on a project in our system. In order to publish the project on our system, they must first pay some fees so the project can be published. When the user clicks publish they are then taken to a shopping cart. The shopping cart has two line items. The line items represent the costs associated with the publishing. When the payment goes through, I then run my stored procedures to update a porject and insert the order with the details. How I have it currently is not in a transaction. I have 3 separate SPs to handle the flow. First, the project data is updated, then an order is inserted, i then use the ID generated by the order insert to insert the data for the details. I am currently looping through the shopping cart and performing each detail insert separately.

I began to create a stored procedure that would execute all the stored procedures, but I got stumped with what to do about the order line items or details.

What is a good solution to bundle all of these tasks into one transaction?



Was it helpful?


System.Transactions are the way to go

You can wrap your operations in a using statement then if anything goes wrong you just dont commit the transaction - very very simple

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow