Technical-Talk banner
Home   About Us   Contact Us
Question:
You are developing an ASP.NET application for the employees of your company so that they can administer their employee benefits. Microsoft SQL server is used to keep the benefits database named BenefitsDB. An employee can select his/her required benefits information from10 dropdown list boxes and the values for each list are stored in separate tables in the database. The benefits information which is listed in the dropdown list boxes can change once in a year. You want your application to hit the database as less as possible to obtain the values for the dropdown list box, Which two options should you choose?
A. Create one DataTable object for each of the 10 dropdown list boxes and one stored procedure that retrieves the results for all 10 dropdown list boxes. Use a SqlDataReader object to populate 10 DataTable objects by calling the NextResult() method. Bind the drop-down list boxes to the DataTable objects.
B. Create only one stored procedure that returns the result set for all 10 drop-down list boxes. Bind the drop-down list boxes to the DataReader object.
C. Create one DataTable object for each dropdown list boxes and a stored procedure for each of the 10 tables. Use a SqlDataReader object to populate the 10 DataTable objects. Bind the drop-down list boxes to the DataTable objects.
D. Store the result sets for the 10 drop-down list boxes in a DataSet object. Add the DataSet object to the Cache object for the application.
E. Store the result sets for the 10 drop-down list boxes in a file on the user’s computer by using the DataSet.WriteXml() method.



Correct Answer: A, D
Explanation:
A: We want to use a single result set provided by a single stored procedure. We are able to use the NextResult() method to retrieve each result in the result set. We also need one DataTable for each drop-down list box and one SqlDataReaderObject.
D: We use a DataSet object to store the result sets for the drop-down list boxes. We cache the result by adding the DataSet object to the Cache object.
Incorrect Answers
B: You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. However, in this scenario we should use SqlDataReader.
C: It would be more effective to create a single stored procedure that returns a single result set.
E: A cache object is preferred to a file in this scenario.

Google