private void Btn_Save_Click(object sender, EventArgs e) { UserView.CommitEdit(DataGridViewDataErrorContexts.Commit); string authID = dvM[AuthView.CurrentRow.Index]["AuthID"].ToString(); string sql = "delete from UserAuthority where AuthID = " + authID; foreach (DataRowView row in dvD) { if (row["isChecked"].ToString() == "1") { sql += ";insert into UserAuthority values(" + authID + "," + row["UserID"].ToString() + ")"; } } try { DbHelperSQL.ExecuteSql(sql); } catch (Exception ex) { MsgBox.ShowInfoMsg(ex.ToString()); } }