You are developing an application that queries a table named Products in a Microsoft SQL Server database. The query will be stored in a string variable named sqlQuery. The query includes the following SQL code:
SELECT * FROM Products FOR XML AUTO
You must iterate the query results and populate an HTML table with product information.
You must ensure that your application processes the results as quickly as possible.
What should you do?
A.
Use a SqlDataAdapter object and set its SelectCommand property to sqlQuery.
Use the Fill method of the SqlDataAdapter object to read the data into a DataSet object.
Loop through the associated rows to read the data.
B.
Use a SqlDataAdapter object and set its SelectCommand property to sqlQuery.
Use the Fill method of the SqlDataAdapter object to read the data into a DataSet object.
Use the ReadXml method of the DataSet object to read the data.
C.
Set the SqlCommand object’s CommandText to sqlQuery.
Use the ExecuteReader method of the SqlCommand object to create a SqlDataReader object.
Use the Read method of the SqlDataReader object to read the data.
D.
Set the SqlCommand object’s CommandText to sqlQuery.
Use the ExecuteXmlReader method of the SqlCommand object to create an XmlReader object.
Use the XmlReader object to read the data.