transaction issue
-
I'm inserting info in database when clicking a button. Some procedure are called. I want to do that with a transaction (when clicking on the button and within its procedure) so that everything will be inserted or nothing. How to do that? Thanks Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) addExtPartyListToDB() AddReminderDB() addCostSplitDB() AddMoneyDB() AddinfoDB() AddmemberDB() end sub
-
I'm inserting info in database when clicking a button. Some procedure are called. I want to do that with a transaction (when clicking on the button and within its procedure) so that everything will be inserted or nothing. How to do that? Thanks Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) addExtPartyListToDB() AddReminderDB() addCostSplitDB() AddMoneyDB() AddinfoDB() AddmemberDB() end sub
you can pass either idbtransaction or iconnection to your methods that update the db
tran = conn.begintranasction try AddReminderDB(tran) tran.rollback catch ex throw finally tran.commit conn.close end try