-
Dec 10th, 2012, 09:09 PM
#1
Thread Starter
Junior Member
Update requires avalid update command when passed data row as collection of rows ?
I am getting an error mentioned in title when i modify all ready saved values and when i press save button the error occurs in this code
Code:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Validate()
Me.ItemsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.ItemsDataSet)
can any body please tell me how to solve the problem . i heard that by inserting sql command builder i can solve this problem but where to put that code. :confused:
-
Dec 10th, 2012, 09:14 PM
#2
Re: Update requires avalid update command when passed data row as collection of rows
That means that your table adapter has no UpdateCommand, which means that the Data Source wizard couldn't generate an UPDATE statement, which most likely means that your database table has no primary key. If there's no primary key then you cannot uniquely identify a record, or at least the system doesn't know how to, which means that it can't generate SQL code to delete or update records. Add a primary key to your database table(s) and regenerate your Data Source.
-
Dec 11th, 2012, 09:29 PM
#3
Thread Starter
Junior Member
Re: Update requires avalid update command when passed data row as collection of rows
i Tried by putting primary key but no use. and i made changes in code see below"get changes" then also no use. please sir could you give me code for sql command builder but inserting i think i can solve my problem i dont where to put even that sql command builder code.
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Validate()
Me.MenuBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MenuDataSet.GetChanges)
End Sub
please sir give me necessary i also ticked refresh box in data set>configure properties but whenever i come back the tick is not selected.
-
Dec 11th, 2012, 09:38 PM
#4
Re: Update requires avalid update command when passed data row as collection of rows
Did you regenerate the Data Source? Adding the primary key to the database is no use if the DataSet doesn't know about it. There's a button in the Data Sources window to run the configuration wizard again. If all else fails, delete the Data Source altogether and create it again from scratch. You can stop asking for alternatives because you don't need alternatives. You just need to do this properly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|