mohaammed talha

mohaammed talha

  • NA
  • 445
  • 47k

It show an error : there is no row at the position

Jan 29 2021 10:50 AM
when the row is empty then its not move to another row and it show an error:there is no row at the position
  1. public void loadAct()  
  2. {  
  3. string qryAct = "";  
  4. DateNow = DateTime.Now.ToString("yyyy-MM-dd");  
  5. DataTable dt2 = new DataTable();  
  6. if (txtDate.Text != "")  
  7. {  
  8. qryAct = "select Line, MAX(TotalPairs)Pairs from ProdHourlyRep where Date= '" + txtDate.Text + "' and Team='C' group by Line";  
  9. }  
  10. else  
  11. {  
  12. qryAct = "select Line, MAX(TotalPairs)Pairs from ProdHourlyRep where Date='" + DateNow + "' and Team='C' group by Line";  
  13. }  
  14. SqlDataAdapter objAdapter2 = new SqlDataAdapter(qryAct, strConn);  
  15. objAdapter2.Fill(dt2);  
  16. if (dt2.Rows.Count > 0)  
  17. {  
  18. lblActl1.Text = dt2.Rows[0][1].ToString();  
  19. lblActl2.Text = dt2.Rows[1][1].ToString();  
  20. lblActl3.Text = dt2.Rows[2][1].ToString();  
  21. //lblActl4.Text = dt2.Rows[3][1].ToString();  
  22. }  
  23. }  

Answers (4)