What should you do?

An application has components named ComponentA, ComponentB, and ComponentC.

ComponentA and ComponentB update tables in a database named DB1.
ComponentC updates tables in a database named DB2.
At run time, ComponentA is executed with either ComponentB or ComponentC in a single transaction.
You need to compose the transaction to minimize the use of the system resources.

What should you do?

An application has components named ComponentA, ComponentB, and ComponentC.

ComponentA and ComponentB update tables in a database named DB1.
ComponentC updates tables in a database named DB2.
At run time, ComponentA is executed with either ComponentB or ComponentC in a single transaction.
You need to compose the transaction to minimize the use of the system resources.

What should you do?

A.
Write the following code for the transaction.
[AutoComplete]
void ExecuteTransactions()
{ …}

B.
Write the following code for the transaction.
void ExecuteTransactions()
{
try
{

ContextUtil.SetComplete();
}
catch
{
ContextUtil.SetAbort();
}
}

C.
Write the following code for the transaction.
void ExecuteTransactions()
{
SqlConnection connection = new SqlConnection(…);
SqlTransaction trans = connection.BeginTransaction();
try
{

trans.Commit();
}
catch
{
trans.Rollback();
}
}

D.
Write the following code for the transaction.
void ExecuteTransactions()
{
using (TransactionScope txscope = new TransactionScope())
{

txscope.Complete();
}
}



Leave a Reply 0

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