2
Reply

delete datagridview records

ta mu

ta mu

Sep 5 2013 5:08 AM
1.2k
i want to delete record which is selected in datagridview from database but i got error

  SqlCommand cmd = new SqlCommand();
               cmd.CommandText = "DELETE FROM addcustomer WHERE ccount_No=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "";
               my.Open();

               cmd.Connection = my;
              cmd.ExecuteNonQuery();


error is
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


plz help me

Answers (2)