private void button1_Click(object sender, EventArgs e)
{
try
{
con.Open();
da = new OracleDataAdapter("select userid, firstname, lastname, salary, location from test_dummy", con);
ds = new DataSet();
cmdbld = new OracleCommandBuilder(da);
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.Columns["userid"].ReadOnly = true;
dataGridView1.Columns["userid"].DefaultCellStyle.BackColor = Color.Red;
dataGridView1.Columns["userid"].DefaultCellStyle.ForeColor = Color.White;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
}
private void button7_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Update?",
"", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes)
{
if (dataGridView1.Columns["location"] == null)
try
{
da.Update(ds.Tables[0]);
MessageBox.Show("Data updated");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
button1_Click(sender, e);
}
if (dataGridView1.Columns["location"] != null)
{
MessageBox.Show("You can not update this line due to location filled");
button1_Click(sender, e);
}
}
if (dialog == DialogResult.No)
{
MessageBox.Show("No change has been made.");
button1_Click(sender, e);
}
}
это код.Как наложить ограничение на строку, чтобы строка с расположением не могла быть удалена, но могла быть обновлена?Я поставил только для чтения, чтобы местоположение не могло быть обновлено, но это не помешает его удалению.Да, я знаю, что могу решить не использовать Commander Builder, чтобы сделать вещи более гибкими, но если я это сделаю, я потеряю свободу редактирования нескольких строк одновременно.Помогите пожалуйста.