Not sure exactly what problem you are having, but I'm going to take a stab
at it. DataReaders are used in a completely different manner than DataSets
and DataTables. DataReader connect to the database and stay open until they
retrieve what they need. As soon as you are done with it, it's gone. A
DataTable/Dataset on the other hand, retains it's values locally.
Typically, you'd populate a DataTable with something like this.
SqlConnection cn = new SqlConnection("myConnectSTring);
SqlCommand cmd= new SqlCOmmand("SELECT whatever from myTable", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
or you can ignore the DataTable for instance and DataSet ds = new DataSet();
da.Fill(ds, "TableNameIWantToUse);
this will populate your DataTable/Set.
Then you can generate your Update/INsert Logic via a commandbuilder, the
DataAdapter Configuration wizard, or roll your own.
then, you can call da.Update(dt);
to iterate through a DataTable
DataRow dr = new DataRow();
foreach (dr in dt.Rows){
//Do Something;
}
DataReader on the other hand, are fired using something like
while dr.Read(){
//do something
}
However, these are used for different puproses and different reasons.
Hopefully this helps..(You may find this helpful, and/or search on your
favorite search engine on DataReader vs. DataTable)
http://dotnetguy.techieswithcats.com/archives/001591.shtml
Cheers,
Bill