What should you do?

A method in your Windows Forms application executes a stored procedure in a Microsoft SQL Server 2005 database, and then executes a second stored procedure in a second SQL Server 2005 database. You need to ensure that the call to the first stored procedure writes changes only if the call to the second stored procedure succeeds. Installation requirements prohibit you from introducing new components that use the COM+ hosting model. What should you do?

A method in your Windows Forms application executes a stored procedure in a Microsoft SQL Server 2005 database, and then executes a second stored procedure in a second SQL Server 2005 database. You need to ensure that the call to the first stored procedure writes changes only if the call to the second stored procedure succeeds. Installation requirements prohibit you from introducing new components that use the COM+ hosting model. What should you do?

A.
Implement a transactional serviced component.Add methods to this component to encapsulate the connect operation and execution of each stored procedure.Register and use this serviced component.

B.
Add a TransactionScope block.Connect to each database and execute each stored procedure within the TransactionScope block.Call the TransactionScope.Complete method if the call to both stored procedure succeeds.

C.
Connect to both databases.Call the SqlConnection.BeginTransaction method for each connection.Call the SqlTransaction.Commit method on both returned transactions only if both stored procedures succeed.

D.
Add a TryCatchFinally block.Connect to each database and execute each stored procedure in the try block.



Leave a Reply 0

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