You use Microsoft .NET Framework 4 to develop an ASP.NET application. The application uses
Integrated Windows authentication. The application accesses data in a Microsoft SQL Server 2008
database that is located on the same server as the application.
You use the following connection string to connect to the database.
Integrated Security=SSPI; Initial Catalog=Adventure¥orks;
The application must also execute a stored procedure on the same server on a database named
pubs.
Users connect to the ASP.NET application through the intranet by using Windows-based
authentication. You need to ensure that the application will use connection pooling whenever
possible and will keep the number of pools to a minimum. Which code segment should you use?
A.
corrrnand.CommandText = “USE [pubs]; exec uspLoginAudit;”
Using connection As New SqlConnection(
“Integrated Security=SSPI;”
“Initial Catalog=AdventureWorks”)
connection.Open()
comnand.ExecuteNonQuery()
End Using
B.
command.CommandText = “exec uspLoginAudit;” Using connection As New SqlConnection(
“Integrated Security=SSPI; “)
connection.Open() command.ExecuteNonQuery()
End Using
C.
command.CommandText = “USE [pubs]; exec uspLoginAudit;” Using connection As New
SqlConnection(
“Initial Catalog=AdventureWorks;” “Integrated Security=SSPI;” “MultipleActiveResultSets=True”)
connection.Open() command.ExecuteNonQuery()
End Using
D.
command.CommandText = “exec uspLoginAudit;” Using connection As New SqlConnection(
“Integrated Security=SSPI; Initial Catalog=pubs”)
connection.Open() command.ExecuteNonQuery()
End Using
Explanation:
Working with Multiple Active Result Sets
(http://msdn.microsoft.com/en-us/library/yf1a7f4f(v=vs.80).aspx)
SSPI
(http://msdn.microsoft.com/en-us/library/windows/desktop/aa380493(v=vs.85).aspx)