I have two DataTables, and I need to populate them from one SqlDataReader.
Reason for this is that I created join in my sql query and I want to populate two tables from reader that contains them.
I used Load method from DataTable but that only works for populating first table because reader's cursor is set to the end after first Load method.
I tried to find the way to copy SqlDataReader, but that didn't work.
Any ides?
Code that I used:
var reader = comm.ExecuteReader();
DataTable1 table1=new DataTable1();
DataTable2 table2=new DataTable2();
table1.Load(reader);
table2.Load(reader);
// table2 is empty because of the first load