0

Why is this code not working?

        (this.namesBindingSource.Current as DataRowView).Delete();         
        this.namesTableAdapter.Update(database1DataSet1);

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

Database is service-based database added to project with only one table which is show in dataGridView and this code is linked to button. You will click on row for delete and then pres button and get error....

What is wrong? I'm getting crazy......

1
  • 1
    What is the value of namesTableAdapter.DeleteCommand property? Commented Jan 10, 2013 at 10:20

2 Answers 2

2

The error message is self explanatory. You need a valid DeleteCommand for namesTableAdapter. Otherwise it does not know you to delete your "deleted" rows. The same is true for Update or Insert-Commands.

Delete() just changes the RowState. If you use a DataAdapter (or TableAdapter) it needs to know what to do if the state is Deleted or Modified.

How to: Create TableAdapter Queries

Sign up to request clarification or add additional context in comments.

1 Comment

HI Tim, thank you very much for answer, but unfortunatelly I don´t have idea how to implemend this. I need to delete row from table when button is pressed.
0

use CommandBuilder but remember you need to use table with a key column in it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.