Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 777.6k

object ref while passing SqlDataReader into DataSet in c#

Aug 24 2017 3:12 AM
Hi Sir,
 
An error is coming while I passing SqlDataReader into DataSet.
 
Kindly go through the code given below and suggest a solution.
  1. sqlRdr = sqlcmd.ExecuteReader();  
  2. while (sqlRdr.Read())  
  3. {  
  4. dgvFeedBack.DataSource = sqlRdr;  
  5. }  
  6. if (!sqlRdr.HasRows)  
  7. {  
  8. RadMessageBox.SetThemeName("Windows7");  
  9. RadMessageBox.Show("\nNo Records found between " + dtFromFeedback.Text + " and " + dtToFeedback.Text, "CollectPlus - Du Feedback", MessageBoxButtons.OK, RadMessageIcon.Exclamation);  
  10. dgvFeedBack.DataSource = null;  
  11. dgvFeedBack.Rows.Clear();  
  12. btnExportData.Enabled = false;  
  13. }  
  14. lblTotalNoOfActions.Text = dgvFeedBack.Rows.Count.ToString();  
  15. DsAllFeedback.Tables.Add().Load(sqlRdr);  
  16. sqlCon.Close();

Answers (3)