private void button1_Click(object sender, EventArgs e)
{
int i;
string conStr = Properties.Settings.Default.connStr;
SqlConnection con = new SqlConnection(conStr);
con.Open();
for (i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
//Here in this for loop you can access all the values of
//gridview and can store it in db by using ado.net like
string query = "insert into Table values(" + dataGridView1.Rows[i].Cells[0].Value + "," + dataGridView1.Rows[i].Cells[1].Value + ")";
SqlCommand cmd = new SqlCommand(query, con);
retval = cmd.ExecuteNonQuery();
}
con.Close();
}