Fill a Typed Dataset from a Stored Procedure that returns Multiple Result sets

This tip explains how to populate a Typed Dataset from a Stored Procedure, which returns multiple result sets. We need to use the DataAdapter TableMappings collection to map the generic t

ITPro Today

May 19, 2004

3 Min Read
ITPro Today logo in a gray background | ITPro Today

This tip explains how to populate a Typed Dataset from a Stored Procedure, which returns multiple result sets.

We need to use the DataAdapter TableMappings collection to map the generic tables to the schema, which is defined in the typed Dataset. When the Data Adapter is used to fill a dataset, the dataset is filled with tables named as Table, Table1, Table2 and so on. So typed Datasets can’t be populated normally.

 

The Stored Procedure

 

 

Shown above is the Stored Procedure, which will be used to populate two tables in the Typed Dataset given below.

 

  1. Employees

  2. Departments

The Typed Dataset

Create a Typed Dataset by dragging and dropping the two tables from the Server Explorer in Design Mode.

 

Code

The following piece of code will help us to populate a typed Dataset directly with the Fill method of the Data Adapter.

 

<span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"> <br><br><br></span>

 

Hope this is useful. Happy Coding!!!!

<span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"> <br><br><br></span>

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like