locked
BindingSource - Connecting VB8 Express Edition to ACCESS 2007

    Question

  • Hi,

    I am connecting the VB8 to Access DB.
    Here is my code:

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    
            Me.Main_TableTableAdapter1.Fill(Me.ToDoDataSet1.Main_Table)
    
    
    
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            BindingSource1.EndEdit()
    
            Dim rowsaffected As Integer = 0
    
            rowsaffected = Main_TableTableAdapter1.Update(ToDoDataSet1.Main_Table)
    
            MessageBox.Show(rowsaffected.ToString)
    
    
    
    
    
        End Sub
    End Class
    

    When i try to change the information of the databes, I am getting the folowing error:


    "Update requires a valid UpdateCommand when passed DataRow collection with modified rows"
    I am able to see the database information but not to change it.

    can somone please help,

    thanks,

    JM


    Wednesday, July 01, 2009 4:49 PM

Answers

  • If you look at the properties for the TableAdapter in the Designer do you have UpdateCommand and InsertCommand statements?
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, July 01, 2009 5:26 PM
  • there could be many reasons for this error.  you can do a google search with the error

    "Update requires a valid UpdateCommand when passed DataRow collection with modified rows"


    first thing i would check is if you have a primary key column.  if not then add one and then refresh the dataset.  or you may have made changes to the database and the dataset does not match.  refresh the dataset. 

    you may have to think back to what you have done and if you changed anything.  highly likely the primary key column is missing.


    FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial
    Wednesday, July 01, 2009 9:11 PM

All replies

  • If you look at the properties for the TableAdapter in the Designer do you have UpdateCommand and InsertCommand statements?
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, July 01, 2009 5:26 PM
  • yes , I checked, I have the update and insert command.
    Wednesday, July 01, 2009 8:28 PM
  • there could be many reasons for this error.  you can do a google search with the error

    "Update requires a valid UpdateCommand when passed DataRow collection with modified rows"


    first thing i would check is if you have a primary key column.  if not then add one and then refresh the dataset.  or you may have made changes to the database and the dataset does not match.  refresh the dataset. 

    you may have to think back to what you have done and if you changed anything.  highly likely the primary key column is missing.


    FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial
    Wednesday, July 01, 2009 9:11 PM