Update requires a valid command

N

N! Xau

Hi all,

I created a dataform using the wizard, everything works fine.
I set both grids to readonly = true, and added a button to switch this
property and save modifications to db. I didn't make any other changes
to the auto-generated code.
But I keep having an error:
"Update requires a valid update command when passed DataRow collection
with modified rows"

Button's click code is:

If bEdit.Text = "Edit" Then
grdMaster.ReadOnly = False
grdDetail.ReadOnly = False
bEdit.Text = "Save"
Else
Try
OleDbDataAdapter1.Update(DSMaster)
OleDbDataAdapter2.Update(DSMaster)
Catch ex As Exception
MsgBox("bEdit: Update failed" & vbCrLf & ex.Message)
End Try
grdMaster.ReadOnly = True
grdDetail.ReadOnly = True
bEdit.Text = "Edit"
End If



thanks for help

N! Xau

Keep in mind the power of ANTANI
http://ilovemiliofede.altervista.org
 
B

Bart Mermuys

Hi,

N! Xau said:
Hi all,

I created a dataform using the wizard, everything works fine.
I set both grids to readonly = true, and added a button to switch this
property and save modifications to db. I didn't make any other changes
to the auto-generated code.
But I keep having an error:
"Update requires a valid update command when passed DataRow collection
with modified rows"

Check if you have two OleDbCommand's for update on the form and check if
they are assigned to the OleDbDataAdapter's (see designer generated code).

The wizard will not create an update command for a table that doesn't have a
primary key. It won't work with db views(joins) either.

You can setup/refresh each OleDbDataAdapter individually by right-clicking
on them and select "configure dataadapter", this way it will warn you if it
couldn't create some of the commands.


HTH,
Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top