locked
Delete Data from Datagridview and Database c# RRS feed

  • Question

  • I am trying to delete data from Datagridview and Database simultaneously but it is not deleting the data from database and showing no error.

    foreach (DataGridViewRow item in this.category_grid.SelectedRows)
                    {
                        string name = item.Cells[0].Value.ToString();
                        connection.Open();
                        OleDbCommand command = new OleDbCommand("delete  from Category where CatName = '" +name+ "'",connection);
                        command.ExecuteNonQuery();
                        category_grid.Rows.RemoveAt(item.Index);
                        connection.Close();
                    }

    Tuesday, December 15, 2020 4:42 AM