Updates requires a valid update command

alander

Well-known member
Joined
Jun 26, 2007
Messages
120
Location
Singapore
Programming Experience
5-10
hi, i am getting a run time exception ..

update requires a valid update command when passed datarow collections with modified rows

i am updating multiple rows of multiple tables at 1 time, i got it right for one of my forms, i did THE SAME for another form that displays other stuff frm my DB but however, i get this error, and i do not understand why becos what i did was the same..

here is my save button


VB.NET:
me.validate()
Wage_RangeBindingSource.EndEdit() 'parent
Wage_RangeTableAdapter.Update(dsSPR1Full.Wage_Range)
CPFBelow35_SPRYear1_Full_BindingSource.EndEdit() 'child1 (update success)
CPFBelow35_SPRYear1_Full_TableAdapter.Update(dsSPR1Full._CPFBelow35_SPRYear1_Full_)
CPF35_50_SPRYear1_Full_BindingSource.EndEdit()'child2 (error Occurs)
CPF35_50_SPRYear1_Full_TableAdapter.Update(dsSPR1Full._CPF35_50_SPRYear1_Full_)

can anyone tell me why?
:confused:
 
Last edited:
eh i still got the error after updating my dataset.. can anyone tell me what happened?
 
Last edited:
Your table has no primary key
The dataset generator cannot automatically work out the update statement for this table because it doesnt know how to uniquely identify one row
No update or delete statement can be generated
You attempted to update data but the update sql is not present

Either write the update sql yourself or
Put a primary key on the table you wish to update
 
Your table has no primary key
The dataset generator cannot automatically work out the update statement for this table because it doesnt know how to uniquely identify one row
No update or delete statement can be generated
You attempted to update data but the update sql is not present

Either write the update sql yourself or
Put a primary key on the table you wish to update



i checked, there was a primary key in all my tables, however i do not understand why my update sql wasnt there, anyway i wrote all of the missing ones by myself thanks
 
Then either you didnt select it as part of the SELECT (the wizard warns you)
You added it after and didnt regenerate the dataset properly (refresh is not enough)
You didnt add a PK at all (i've had this before) or you have confused a unique index with a PK (they arent the same)
You are selecting from something that is inherently not updateable, like a view
Your sql contains syntax the wizard doesnt recognise (you see an error)
You updated the wrong database with the PK details (debug vs release db, it happens quite a lot)
 
Back
Top