You are creating a Windows Forms application that includes the database
helper methods UpdateOrder and UpdateAccount. Each method wraps code that connects to a Microsoft SQL Server 2005 database, executes a Transact-SQL statement, 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?
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)){
UpdateOrder();
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 TransactionScope(TransactionScopeOption.Required)){
UpdateAccount();
ts.Complete();
}