I was looking at a code of someone who used cn.BeginTrans
right before deleting a Table. The code looked something like this
cn.BeginTrans
//Update or delete table code
cn.CommitTrans
I played around with BeginTrans and UpdateTrans and I understand what it does. It is basically like version control where BeginTrans
= git add
and git commit
and UpdateTrans
= git push
. At least this is how I understand it.
What I do not understand is the fact that Commitrans
is used immediately after begintrans
. If the code is committed according to this stackoverflow post there is no way to rollback.
Why not just delete or update the table without using the Trans method if you are going to Commit immediately?