PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Windows Forms application that includes the database helper methods UpdateOrder and UpdateAccount.
Each method wraps code that connect to a Microsoft SQL Server 2005 database, executes a Transact-SQL statment, and then disconnects from the database. You must ensure that changes to the database that result from the UpdateAccount method are committed only if the UpdateOrder method succeeds.
You need to execute the UpdateAccount method and the UpdateOrder method. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
using (TransactionScope ts = new TransactionScope())
{
UpdateOrder();
UpdateAccount();
ts.Complete();
}

B.
using (TransactionScope ts1 = new TransactionScope())
{
UpdateOrder();
using (TransactionScope ts2 = new
TransactionScope(TransactionScopeOption.RequiresNew))
{
UpdateAccount();
ts2.Complete();
}
ts1.Complete();
}

C.
using (TransactionScope ts = new
TransactionScope(TransactionScopeOption.RequiresNew))
{
UpdateOrders.();
ts.Complete();
}
using (TransactionScope ts = new
TransactionScope(TransactionScopeOption.Required))
{
UpdateAccount();
ts.Complete();
}

D.
using (TransactionScope ts = new
TransactionScope(TransactionScopeOption.RequiresNew))
{
UpdateOrder();
}
using (TransactionScope ts = new


Leave a Reply