3.13. Executing a Query That Returns Multiple Result Sets

Problem

You have a batch SQL query that returns multiple result sets and you need to work with the result sets in ADO.NET.

Solution

Use the techniques shown in this solution to use a batch query with both a DataSet and with a DataReader.

The solution defines a SQL batch query statement that selects the top three rows of each Sales.SalesOrderHeader and Sales.SalesOrderDetails from AdventureWorks.

A DataAdapter is used to load the multiple result sets into a DataSet. The data values in the DataSet are accessed through the collection of DataTable objects in the DataSet and output...