title: Need help resolving an error that says, no row at position 0
body: <p>I am working on a c# project and in this project, I want to select some data and show in a datagridview but I have data in my database and I have a query of select but when I click the button so I get this type of error this no row at position 0</p>
  
  <p>Here are the screenshots</p>
  
  <ul>
  <li><a href="https://imgur.com/PKvcgY9" rel="nofollow noreferrer">https://imgur.com/PKvcgY9</a></li>
  <li><a href="https://imgur.com/aeq0weF" rel="nofollow noreferrer">https://imgur.com/aeq0weF</a></li>
  <li><a href="https://imgur.com/8AG3LZ4" rel="nofollow noreferrer">https://imgur.com/8AG3LZ4</a></li>
  </ul>
  
  <p>Here is my code</p>
  
  <pre><code>dataGridView4.Columns.Add("", "Leave Consumed");
  dataGridView4.Columns.Add("", "Leave Allaowed");
  dataGridView4.Columns.Add("", "Balance");
  
  for (int i = 0; i &lt; dataGridView4.Rows.Count; i++)
  {
      DataSet ds1211122 = new DataSet();
      DataTable dt1211122 = new DataTable();
      ds1211122.Tables.Add(dt1211122);
  
      OleDbDataAdapter da1211122 = new OleDbDataAdapter();
      da1211122 = new OleDbDataAdapter("SELECT Sum(USERID) FROM [CHECKINOUT] where " + 
          "[CHECKTYPE]= '" + "I" + "'AND [USERID] = " + 
          dataGridView4.Rows[0].Cells[1].Value.ToString() + "AND [CHECKTIME] Between #" + 
          dateTimePicker2.Value.ToString() + "# AND #" + 
          dateTimePicker1.Value.ToString() + "# Group By [USERID];", VCON);
  
      da1211122.Fill(dt1211122);
  
      int num = 0;
      num = Convert.ToInt32(dt1211122.Rows[0][0].ToString());
      VCON.Close();
  }
  </code></pre>