PrepAway - Latest Free Exam Questions & Answers

What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application contains the following code segment. (Line numbers are included for reference only.)

01 Class DataAccessLayer
02 Private Shared connString As String
03 04 …
05 Public Shared Function GetDataTable(command As String) As DataTable
06 07 …
08 End Function
09 End Class

You need to define the connection life cycle of the DataAccessLayer class. You also need to ensure that the application uses the minimum number of connections to the database. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Insert the following code segment at line 03. Private Shared conn As New SqlConnection(connString) Public Shared Sub Open() conn.Open() End Sub Public Shared Sub Close() conn.Close() End Sub

B.
Insert the following code segment at line 03. Private conn As New SqlConnection(connString) Public Sub Open() conn.Open() End Sub Public Sub Close() conn.Close() End Sub

C.
Replace line 01 with the following code segment. Class DataAccessLayer Implements IDisposable Insert the following code segment to line 03.
Private conn As New SqlConnection(connString) Public Sub Open() conn.Open() End Sub Public Sub Dispose() conn.Close() End Sub

D.
Insert the following code segment at line 06. Using conn As New SqlConnection(connString) conn.Open() End Using


Leave a Reply