Q:
You develop an enterprise application, called XYZApplication that includes a Windows Form presentation layer, middle-tier components for business logic and data access, and a Microsoft SQL Server database.
You are in the process of creating a middle-tier component that will execute the data access routines in your application. When data is passed to this component, the component will call several SQL Server stored procedures to perform database updates. All of these procedure calls run under the control of a single transaction.
The code for the middle-tier component will implement the following objects:
SqlConnection cn = new SqlConnection();
SqlTransaction tr;
If two users try to update the same data concurrently, inconsistencies such as phantom reads will occur. You must now add code to your component to specify the highest possible level of protection against such inconsistencies.
Which code segment should you use?
Answer & Explanation
Answer: C) tr = cn.BeginTransaction(IsolationLevel.Serializable);
Explanation: Serializable is the highest isolation transaction level. It provide the highest possible level of protection against concurrent data errors. The correct syntax to begin a transaction with this transaction isolation level is: cn.BeginTransaction(IsolationLevel.Serializable)
View Answer
Report Error
Discuss