Hello,

I have an problem with updating a database after I have deleted or edited a database row in VB.NET. When I insert a new row it works well.

When I delete I get the following error message:
Update requires a valid DeleteCommand when passed DataRow collection with deleted rows
And when I edit I get the following message:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows

Does someone know the code I need?

Here is the code I use and that does not work:
For deleting:

[INDENT]Me.KlantBindingSource.RemoveCurrent()
        Me.Validate()
        Me.KlantBindingSource.EndEdit()
        KlantTableAdapter.Update(Me.DataDataSet)[/INDENT]

For editing:

[INDENT]Me.Validate()
        Me.KlantBindingSource.EndEdit()
        KlantTableAdapter.Update(Me.DataDataSet)[/INDENT]

The name of mine bindingsource is KlantBindingSource, the name of mine TableAdapter is KlantTableAdapter and the name of mine DataSet is DataDataSet.

I am using Microsoft Visual Studio 2008

Try checking the properties of the KlantTableAdapters update & delete commands to see if they are valid.

If the table being affected has no primary key this can also cause this type of problem.

Thanks for your answer. I forgot the primary key

Your Welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.