Microsoft
70-516 · Question #57
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database. The application includes a SqlConnection named…
The correct answer is A. var transaction = conn.BeginTransaction(). See the full explanation below for the reasoning.
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database. The application includes a SqlConnection named conn and a SqlCommand named cmd. You need to create a transaction so that database changes will be reverted in the event that an exception is thrown. Which code segment should you use?
Options
- Avar transaction = conn.BeginTransaction();
- Bvar transaction = conn.BeginTransaction();
- Cvar transaction = conn.BeginTransaction();
- Dvar transaction = conn.BeginTransaction();
How the community answered
(54 responses)- A85% (46)
- B2% (1)
- C4% (2)
- D9% (5)
Community Discussion
No community discussion yet for this question.