Skip to content
Advertisement

How to fill Dataset with multiple tables?

I’m trying to fill DataSet which contains 2 tables with one to many relationship. I’m using DataReader to achieve this :

But I’ve got only one table filled up. How do I achieve my goal – fill both tables?

I would like to use DataReader instead DataAdapter, if it possible.

Advertisement

Answer

If you are issuing a single command with several select statements, you might use NextResult method to move to next resultset within the datareader: http://msdn.microsoft.com/en-us/library/system.data.idatareader.nextresult.aspx

I show how it could look bellow:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement