954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with updating database after delete or edit

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

Jemjoo
Newbie Poster
8 posts since Jul 2008
Reputation Points: 11
Solved Threads: 2
 

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.

RipperJT
Newbie Poster
23 posts since Jan 2007
Reputation Points: 13
Solved Threads: 3
 

Thanks for your answer. I forgot the primary key

Jemjoo
Newbie Poster
8 posts since Jul 2008
Reputation Points: 11
Solved Threads: 2
 

Your Welcome!

RipperJT
Newbie Poster
23 posts since Jan 2007
Reputation Points: 13
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You