forum

Home / DeveloperSection / Forums / Data Table loads only last record of mysqlDataReader

Data Table loads only last record of mysqlDataReader

Manoj Bhatt222301-Sep-2014

In my page mysqlDataReader returns 4 records.Whenever I load this mysqlDataReader to DataTable using 

DataTable dt = new DataTable();

dt.Clear();

dt.Load(dr);

DataTable shows only last record.

my Code is:

DataTable dt = new DataTable();

for (int i = 0; i < gvDemoBatches.Rows.Count; i++)

{

     CheckBox cb = (CheckBox)gvDemoBatches.Rows[i].FindControl("checkSelect");

     if (cb.Checked == true)

     {

         Panel2.Visible = true;

         objBEBatch.BatchID = Convert.ToInt32(((Label)gvDemoBatches.Rows[i].Cells[0].FindControl("lblBatchId")).Text);

          MySqlDataReader dr = objBLAddNewDemo.GetParticularDemoData(objBEBatch);

         dt.Clear();

         dt.Load(dr);

      }

 }

"GetParticularDemoData" stored Procedure Returns 7 rows.but datatable shows only last record.


Updated on 01-Sep-2014

Can you answer this question?


Answer

1 Answers

Liked By