Results 1 to 4 of 4

Thread: Update requires avalid update command when passed data row as collection of rows ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    26

    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:
    Name:  Capture.JPG
Views: 134
Size:  56.0 KB

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    26

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    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
  •  



Click Here to Expand Forum to Full Width