Israel

Israel

  • 699
  • 1.3k
  • 217.5k

Delete multiple rows

Mar 15 2019 9:13 AM
Hi,
 
I wrote a little codes to select multiple rows from my datagridview and delete at once from my database. Its delete all the selected rows from my datagridview but curiosly its doesnt delete from my database. I can resolv it please. Thank you.
 
private void button1_Click(object sender, EventArgs e)
{
conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\Flexit_GovFAA\\Forcas_Armadas_Angolanas\\App_Datas\\FlexAccounting.mdf;Integrated Security = True");
comm = new SqlCommand();
if (conn.State != ConnectionState.Open)
conn.Open();
foreach (DataGridViewRow item in this.dgvLivro1.SelectedRows)
{
dgvLivro1.Rows.RemoveAt(item.Index);
}
}
 

Answers (3)