private void button1_Click(object sender, EventArgs e) { try { StorePhone.SQLDatabase.ExcDataTable("DBCC CHECKIDENT ('[tonghopcol]', RESEED, 0); delete from tonghopcol"); foreach (DataGridViewRow row in dataGridView1.Rows) { dm_tonghopcol dm = new dm_tonghopcol(); dm.id = ConvertType.ToInt(row.Cells["id"].Value); dm.ten = row.Cells["ten"].Value.ToString(); dm.cot = row.Cells["cot"].Value.ToString(); SQLDatabase.Adddm_tonghopcol(dm); //dataGridView1.CurrentCell = dataGridView1.Rows[row.Index].rows[0]; } BindData(); } catch (Exception ex) { MessageBox.Show(ex.Message, "button1_Click"); } }