Help make sure that when you click on the button, the selected line in the DataGridView is deleted from the database
I found an answer on the Internet, but this function does not remove the selected value from the database, and when the table is updated, they reappear
private void button4_Click(object sender, EventArgs e) { foreach (DataGridViewRow item in this.dataGridView1.SelectedRows) { dataGridView1.Rows.RemoveAt(item.Index); } } Here's how the data is connected to the DataGridView
private void button1_Click(object sender, EventArgs e) { con.Open(); OracleDataAdapter oda = new OracleDataAdapter("select *from nebera_stadion", con); DataTable dt = new DataTable(); oda.Fill(dt); dataGridView1.DataSource = dt; dataGridView1.Columns["id_stadion"].Visible = false; con.Close(); }
DataSet,DataAdapter,DataTablefrom ADO.Net. you need to create an application model from the classes, and for binding use theBindingSource. - BulsonDataAdapter, you need to call itsUpdatemethod. In this case, the propertiesUpdateCommand,DeleteCommandmust be set. - Alexander Petrov