You are an enterprise application developer. You create a component that executes queries against Microsoft SQL Server. The queries are executed inside the scope of a transaction. The transaction is started by using the SqlTransaction object. The code executes the query inside a Try block. You need to create an exception handling mechanism that rolls back the transaction under any error condition and notifies the caller of the error. What should you do?
A.
Use a catch block to catch all exceptions. Roll back the transaction and rethrow the exception inside the catch block.
B.
Place code to roll back the transaction inside a finally block.
C.
Place the SqlTransaction object inside a using statement.
D.
Use a catch block to catch all exceptions. Rethrow the exception inside the catch block and roll back the transaction in the finally block.