Home » Microsoft » 70-487 v.2 » How should you complete the code?
HOTSPOT
You are creating an application that retrieves Microsoft SQL Server data from two tables named Product and ProductModel.
You need to store in two separate lists all the names of the products and the product models for later use by the application.
How should you complete the code? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:
Correct Answer:
Explanation/Reference:
Explanation:
Box 1:
Two Select statements to get two results.
Box 2: (Reader.Read());
The SqlDataReader.Read Method advances the SqlDataReader to the next record. The default position of the SqlDataReader is before the first record. Therefore, you must call Read to begin accessing any data.
Return Value
Type: System.Boolean true if there are more rows; otherwise false.
Box 3: Reader.NextResult();
The SqlDataReader.NextResult method advances the data reader to the next result, when reading the results of batch Transact-SQL statements. Used to process multiple results, which can be generated by executing batch Transact-SQL statements.
By default, the data reader is positioned on the first result.
Box 4: (Reader.Read());
References: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.nextresult(v=vs.110).aspx