You need to ensure that a database transaction is rolled back if an exception occurs during an operation. Which ADO.NET construct should you use for this purpose?

  • Data Reader
  • Data Set
  • TransactionScope
  • Try-Catch Block
In ADO.NET, you can ensure that a database transaction is rolled back if an exception occurs during an operation by using a Try-Catch Block. Within the Try block, you initiate the transaction, perform database operations, and commit the transaction if successful. In case of an exception, control passes to the Catch block where you can handle the exception and roll back the transaction to maintain data consistency and integrity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *