70-516 · Question #187
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to two different Microsoft SQL Server 2008 database servers named Server1 and…
The correct answer is B. Insert the following code segment at line 02. Here cn1 is for the Ambient Transaction (i.e the lightweight or logical transaction) that will be used run the 2 transactions in the ambient scope. If the cn1 transaction fails, then the requirement is for the cn2 transaction NOT to join the ambient transaction. It needs to run…
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to two different Microsoft SQL Server 2008 database servers named Server1 and Server2. A string named sql1 contains a connection string to Server1. A string named sql2 contains a connection string to Server2. 01 using (TransactionScope scope = new 02 ... 03 ) 04 { 05 using (SqlConnection cn1 = new SqlConnection(sql1)) 06 { 07 try{ 08 ... 09 } 10 catch (Exception ex) 11 { 12 } 13 } 14 scope.Complete(); 15 } You need to ensure that the application meets the following requirements:
- There is a SqlConnection named cn2 that uses sql2.
- The commands that use cn1 are initially enlisted as a lightweight
transaction. The cn2 SqlConnection is enlisted in the same TransactionScope only if commands executed by cn1 do not throw an exception. What should you do?
Options
- AInsert the following code segment at line 02.
- BInsert the following code segment at line 02.
- CInsert the following code segment at line 02.
- DInsert the following code segment at line 02.
How the community answered
(22 responses)- A5% (1)
- B77% (17)
- C14% (3)
- D5% (1)
Explanation
Here cn1 is for the Ambient Transaction (i.e the lightweight or logical transaction) that will be used run the 2 transactions in the ambient scope. If the cn1 transaction fails, then the requirement is for the cn2 transaction NOT to join the ambient transaction. It needs to run within its own independent transaction. This is achieved by using TransactionScopeOption. If the cn2 transaction does NOT fail, then both transactions will run under the ambient TransactionScopeOption Required A transaction is required by the scope. It uses an ambient transaction if one already exists. Otherwise, it creates a new transaction before entering the scope. This is the default RequiresNew A new transaction is always created for the scope. Suppress The ambient transaction context is suppressed when creating the scope. All operations within the scope are done without an ambient transaction context.
Topics
Community Discussion
No community discussion yet for this question.