1
Answer

deleting row in mysql from datagridview

siva reddy

siva reddy

15y
7.1k
1
i tried to delete data from datagridview . it is not deleting row in mysql but removes in datagridview.
My code is

 private void update_Click(object sender, EventArgs e)
      {
          DataTable dt = ds.Tables["distributor"];
         this.dataGridView1.BindingContext[dt].EndCurrentEdit();
            this.da.Update(dt);

        
      }

      private void delete_Click(object sender, EventArgs e)
      {
          if (dataGridView1.SelectedRows.Count == dataGridView1.Rows.Count)
          {
              dataGridView1.Rows.Clear();
          }
          foreach (DataGridViewRow row in dataGridView1.SelectedRows)
          {
              dataGridView1.Rows.Remove(row);
          }
      }
pls help me.
thank you
Answers (1)