Hope someone can help / point me in the right direction, as I have been looking this up for some while, and am stumped.
I have VB 2010 accessing Access via the normal OLEDB connection (project data source). A Form containing MASTER/DETAIL Records - created by making a dataset from both tables, setting the relationship to cascade all changes etc and with FK + relation constraints). Simply dropped the MASTER Data Source onto the form as detail records, and then the subordinate DETAIL table as a Datagridview.
I am loading the MASTER first, and applying updates MASTER then Child ( as I believe I should)
Save code - autogenerated..
Me.Validate()
Me.PurchasesBindingSource.EndEdit()
Me.PurchaseItemsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.PURCHASESDataSet)
The form correctly displays the right detail records, and allows me to ADD new child records. BUT - If I add a new MASTER, then go straight to CHILD - I get an error immediately advising that I have violated Foreign Key Constraints (ie; my FK in the detail table is showing as -1 and has no corresponding Master Records.
Appreciate I must be doing something basically wrong, but this sort of thing worked fine back in VB6, and whilst I have a work-around - this simple conundrum is driving me mad.
Help appreciated please
Steve
I have VB 2010 accessing Access via the normal OLEDB connection (project data source). A Form containing MASTER/DETAIL Records - created by making a dataset from both tables, setting the relationship to cascade all changes etc and with FK + relation constraints). Simply dropped the MASTER Data Source onto the form as detail records, and then the subordinate DETAIL table as a Datagridview.
I am loading the MASTER first, and applying updates MASTER then Child ( as I believe I should)
Save code - autogenerated..
Me.Validate()
Me.PurchasesBindingSource.EndEdit()
Me.PurchaseItemsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.PURCHASESDataSet)
The form correctly displays the right detail records, and allows me to ADD new child records. BUT - If I add a new MASTER, then go straight to CHILD - I get an error immediately advising that I have violated Foreign Key Constraints (ie; my FK in the detail table is showing as -1 and has no corresponding Master Records.
Appreciate I must be doing something basically wrong, but this sort of thing worked fine back in VB6, and whilst I have a work-around - this simple conundrum is driving me mad.
Help appreciated please
Steve