Can't save changes made through Combobox

Hello everybody,

I am very very new to VB2005. But I love the designer.
My problem is the following:

I have a form: form1 based on Table1 through a Dataset, Bindingsource, etc... all set in the designer.

On that form I have some fields:
-ID
-Item_ID

I also have a comobox on the form that is bound to another table: Table2
I set the following properties of that Combobox:
Datasource: Table2
Displaymember: Table2_DescriptionField
ValueMember: Table2_ID

When I start the form and I navigate through the records it works fine.
But when I hit the save button I get the following Error message:
"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."
I hope I descriped My problem good enough.
The following code is included in my form:
Public Class frmBron

Private Sub TblBRONBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblBRONBindingNavigatorSaveItem.Click
Me.Validate()
Me.TblBRONBindingSource.EndEdit()
Me.TblBRONTableAdapter.Update(Me.ILL2006DataSet.tblBRON)

End Sub

Private Sub frmBron_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ILL2006DataSet.tblBRONSOORT' table. You can move, or remove it, as needed.
Me.TblBRONSOORTTableAdapter.Fill(Me.ILL2006DataSet.tblBRONSOORT)
'TODO: This line of code loads data into the 'ILL2006DataSet.tblBRON' table. You can move, or remove it, as needed.
Me.TblBRONTableAdapter.Fill(Me.ILL2006DataSet.tblBRON)

End Sub

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
'Sluit het huidige formulier af
Me.Close()
End Sub
End Class

Thank you guys in advance...


Answer this question

Can't save changes made through Combobox

  • FernandoLeite

    The conbobox should be bound to the table1 binding source and table2 should be a subset/child of table1 and then setup your cobobox binding as such:

    Table1

    Id

    ItemId

    Table2

    ItemId

    DescriptionField

    Combobox:

    Datasource: Table2
    Displaymember: Table2_DescriptionField
    ValueMember: Table1_ItemID



  • Can't save changes made through Combobox