PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Windows Forms application. The application uses a SqlCommand object named cmd. The cmd object executes the following stored procedure.

CREATE PROCEDURE GetPhoneList
AS
BEGIN
SELECT CompanyName, Phone FROM Customers
SELECT CompanyName, Phone FROM Suppliers
END

You need to add all returned rows to the ListBox control named lstPhones. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Dim rdr As SqlDataReader = cmd.ExecuteReader()Do While rdr.Read() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1))) End WhileLoop While rdr.NextResult()

B.
Dim rdr As SqlDataReader = cmd.ExecuteReader()While rdr.Read() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1)))End While

C.
Dim rdr As SqlDataReader = cmd.ExecuteReader()While rdr.NextResult() While rdr.Read() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1))) End WhileEnd While

D.
Dim rdr As SqlDataReader = cmd.ExecuteReader()While rdr.NextResult() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1)))End While


Leave a Reply