Either your table does not have 8 columns, or the number of rows you are reading as the first column in each row does not match the rows count for the DataGridView.
Use the debugger: put a breakpoint on the line
dataGridView1.Rows[r].Cells[c].Style.ForeColor = Color.Green;
And look at the value of
r
and
c
to check which is out of range.