It is necessary to realize by pressing the delete button, selected in the DGV, records from the database, preferably the syntax.

I tried this:

if (tovarDataGridView.CurrentRow != null) { tovarBindingSource.RemoveCurrent(); tovarBindingSource.EndEdit(); tovarTableAdapter.Update(this.optDBData.tovar); this.tovarTableAdapter.Fill(this.optDBData.tovar); } 

Error: Update element requires a valid DeleteCommand when transferring a DataRow collection with deleted rows.

It is necessary to delete the record selected in DGV even if it is just a cell and not the whole line!

  • By pressing a button? And what's your handler button? The error indicates that the DeleteCommand field is not filled in - you need to write a deletion script (preferably with a key), the key is a separate story. Is it also a Web or desktop application? - nick_n_a
  • @nick_n_a is WinForms, the usual Button handler, so how do I implement the deletion? it is necessary to delete the record selected in DGV (even if it is just a cell and not the whole line) - Vyacheslav
  • Set your adapter's DeleteCommand property. - Alexander Petrov
  • @AlexanderPetrov and what should be in DeleteCommand, what is the syntax? - Vyacheslav
  • Depends on DataSource. The sqldatasource sql syntax. In procedural - the name of the procedure. Look at the syntax in SelectCommand - in DeleteCommand in the same way. - nick_n_a

0