tags:

views:

12

answers:

0

I'm using vb.net. I have two tables - a Parent and Child. They are in DataSet/DataTables (disconnected). I Add a Parent record (in code) and a several Child record (DataGridView Bound to the Child Table - code bellow). I notice that the parent Identity is 0, and when I save it all (using the ADO Update (from the SQLCommandBuilder) the Child Table has nothing in the Column that should contain the Parent FK.

' here the binding source / relation gets setup

Dim myDR As New DataRelation("ProductionRelation", ProductionCostDS.Tables("tblProductionCostHeader").Columns("ProductionCostHeaderID"), _
                                          ProductionCostDS.Tables("tblProductionCostDetail").Columns("ProductionCostHeaderID"))
ProductionCostDS.Relations.Add(myDR)
ProductionCostHeaderBS.DataSource = ProductionCostDS
ProductionCostHeaderBS.DataMember = "tblProductionCostHeader"
productionCostDetailBS.DataSource = ProductionCostHeaderBS
productionCostDetailBS.DataMember = "ProductionRelation"

' here it is bound to the datagridview

Me.DataGridView1.DataSource = productionCostDetailBS