One of the assistant application developers named Rory Allen were asked to execute two SQL commands which can update the data in separate Microsoft SQL Server 2005 databases. When ever the second command fails, the first command should be rolled back. What should Rory Allen do?
A.
Execute both the commands within a single TransactionScope block and call the Complete method of the TransactionScope instance if both commands execute successfully.
B.
Execute both the commands in separate TransactionScope block and call the Complete method of the second TransactionScope instance if both commands execute successfully.
C.
Execute both the commands within a single TransactionScope block and call the Complete method of the TransactionScope instance if each command executed successfully.
D.
Execute both the commands in separate TransactionScope block and call the Complete method of the TransactionScope instance if each command executed successfully.
Explanation:
Both of the commands should be executed within a single TransactionScope block. This will allow both of the commands to execute within the same context of the same transaction.Incorrect Answers:
B, D: You should not execute each command in a separate TransactionScope block. Both of the commands should be executed within a single TransactionScope block.