ta mu

ta mu

  • NA
  • 201
  • 82.2k

delete datagridview records

Sep 5 2013 5:08 AM
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)