Office Document APIs for .NET
ITIL Career Advice
PMP Career Advice
Android Intel XDK
Welcome Guest !
You are debugging an issue with an application that uses nested transactions. You notice that the following code executes without throwing an exception:
using (TransactionScope scope = new TransactionScope())
using (SqlConnection connection1 = new SqlConnection(connectString1))
SqlCommand command1 = new SqlCommand(updateCommandText, connection1);
using (SqlConnection connection2 = new SqlConnection(connectString2))
SqlCommand command2 = new SqlCommand(insertCommandText, connection2);
However, you notice that the database changes are not persisted. You must ensure that when Complete is called, changes are persisted.
What should you do?
on 9/30/2012 | Category:
ADO.NET Interview questions
| Views: 1212 |
Select from following answers:
Set the TransactionScopeOption to RequiresNew.
Set the TransactionScopeOption to Required.
Add the Enlist=true setting to the connection strings.
The call to the Complete method does not commit the changes. In this case the transaction scope could use an ambient transaction, which could fail independently of this code and cause this code to roll back even after the Complete method was called. Setting the scope of this transaction to RequiresNew always makes it the root scope. It starts a new transaction, and this transaction becomes the new ambient transaction inside the scope. When this code completes the transaction, the changes are completed, committed, and, therefore, persisted.
By default, the transaction scope is Required. If the scope is instantiated with Required and an ambient transaction is present, the scope joins that transaction. This is not the desired behavior.
Show Correct Answer
MeasureUp.Com | |
< Previous :
You are debugging an issue with an application tha ...
Next > :
You add the following code to begin a transactiona ...
Comments or Responses
Login to post response
More Interview Questions by Rajkatie
You add the following code to begin a transactional code block: Tra ...
You are debugging an application that uses transactions to ensure data ...
You use two DataContext instances to retrieve objects from two databas ...
You add a method that executes an INSERT command to write state inform ...
You add a method that updates tables with two update commands. These c ...
You are writing a component that uses a TransactionScope to ensure tra ...
You are writing an application that accesses a single Microsoft SQL Se ...
You are implementing an application that uses Entity Framework-generat ...
Latest Interview Questions
How to Create Database and Tables insert,edit,Delete using Procedure?
How to publish service metadata?
What is a metadata export?
How can we specify the throttling behavior for a WCF service?
What is a Throttling behavior in WCF?
Explain the functionality of the Message layer in WCF.
Give an example of a duplex service
How can you specify a duplex service?