Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Transaction method in c#, i do some transactions to 4 Sql server tables inside of that method

Ex:

1st - : Insert to PurchaseMaster Table
2nd - : Insert to PurchaseDetail Table
3rd - : Update ItemMaster Table
4th - : Insert/Update ItemDetail Table

if there some exception happens how can i roll back all these 4 table ?
Posted
Comments
[no name] 17-Oct-15 13:53pm    
And what is the Problem? Transactions are exactely the tool for this.
START TRANS
...do a lot of things
COMMIT OR ROLLBACK depending on you...
PIEBALDconsult 17-Oct-15 14:16pm    
First, put all the changes in one transaction.
sreeyush sudhakaran 18-Oct-15 6:55am    
If your Database is SQLServer 2005 above I suggest you to use Transaction with in Stored Procedure and Use these Tables as Custom table valued Parameters type for the stored procedure

Refer : http://how2doinvbdotnet.blogspot.ae/2015/09/how-to-use-table-value-parameters-in.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900