PrepAway - Latest Free Exam Questions & Answers

You need to retrieve all of the results from the stored procedure

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database. You add the following stored procedure to the database.
CREATE PROCEDURE GetSalesPeople
AS
BEGIN
SELECT FirstName, LastName, Suffix, Email, Phone
FROM SalesPeople
END
You write the following code. (Line numbers are included for reference only.)
01 Dim connection As SqlConnection = New SqlConnection(“& “)
02 Dim command As SqlCommand = New SqlCommand(“GetSalesPeople”, connection)

03 command.CommandType = CommandType.StoredProcedure
04
You need to retrieve all of the results from the stored procedure. Which code segment should you
insert at line 04

PrepAway - Latest Free Exam Questions & Answers

A.
Dim res = command.ExecuteReader()

B.
Dim res = command.ExecuteScalar()

C.
Dim res = command.ExecuteNonQuery()

D.
Dim res = command.ExecuteXmlReader()

Explanation:
ExecuteReader Sends the CommandText to the Connection and builds a SqlDataReader.
SqlCommand Class
(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx)


Leave a Reply