I want to create a C# application in which copy some files in two diffrent folders(already contains older version files) and also run sql scripts. During whole process if any exception generate i need to rollback all the changes.
For sql scripts, transation can be used but how implement files copying process with rollback?
In SQL, ROLLBACK is a command that causes all data changes since the last BEGIN WORK , or START TRANSACTION to be discarded by the relational database management systems (RDBMS), so that the state of the data is "rolled back" to the way it was before those changes were made.
Rolls back an explicit or implicit transaction to the beginning of the transaction, or to a savepoint inside the transaction. You can use ROLLBACK TRANSACTION to erase all data modifications made from the start of the transaction or to a savepoint. It also frees resources held by the transaction.
A DBMS feature that reverses the current transaction out of the database, returning the data to its former state. A rollback is performed when processing a transaction fails at some point, and it is necessary to start over.
No, you can't undo, rollback or reverse a commit.
You can take advantage of Transactional NTFS if possible. If not, then you can keep a list of the operations you did and do the reverse of it when a rollback is needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With