private void button1_Click(object sender, EventArgs e)
{
int i = 1;
int j = dataGridView1.Rows.Count;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
if (i < j)
{
i++;
string a = row.Cells[0].Value.ToString();
string b = row.Cells[1].Value.ToString();
SqlConnection conn = new SqlConnection(@"Data Source=PC-200908101229/SQL2005;Initial Catalog=student;Integrated Security=True");
conn.Open();
SqlCommand comm = new SqlCommand("insert into T_student(Name)values('" + b + "')", conn);
comm.ExecuteNonQuery();
conn.Close();
}
}
//MessageBox.Show(j.ToString());
}