Hi, who knows how to update the 'child' textboxes in a datarelated situation
if the child records "doesn't yet exitsts/are still empty"?
The problem can be explained with the Northwind database.
Parenttable = Customers with some databound textboxes
Childtable = Orders with some databound textboxes
Parent-Child Datarelation on field CustomerId
I.e. Customer FISSA doesn't yet have Orders. So when I navigate (code not
supplied) to customer FISSA the Orders textboxes are empty. Just
typing/filling the textboxes for "ShipCity" and "ShipCountry" succeed
however these values aren't kept. When you navigate to the next customer and
back again to the previous the typed in values are gone! Is het necessary to
add a new order row, and should the CustomerId be filled manually? Help
would be appreciated.
*** START CODEEXAMPLE ***
myConnection = New
SqlConnection("server=(local);Trusted_Connection=y es;database=northwind")
mySqlDataAdapter1 = New SqlDataAdapter("select * from Customers",
myConnection)
mySqlDataAdapter2 = New SqlDataAdapter("select * from Orders", myConnection)
mySqlDataAdapter1.Fill(myDataSet, "Customers")
mySqlDataAdapter2.Fill(myDataSet, "Orders")
'Define relation
myDataSet.Relations.Add(New DataRelation( _
relationName:="relCustomersOrders", _
parentColumn:=myDataSet.Tables("Customers").Column s("CustomerId"), _
childColumn:=myDataSet.Tables("Orders").Columns("C ustomerId"), _
createconstraints:=True))
'Create dataview
dv1 = New DataView
With dv1
.Table = myDataSet.Tables("Customers")
.AllowDelete = True
.AllowEdit = True
.AllowNew = True
.RowFilter = ""
.Sort = "CompanyName DESC"
End With
bmb = Me.BindingContext(dv1)
'textboxen databinding 'Customers-table'
txtCustomerId.DataBindings.Add("Text", dv1, "CustomerId")
txtCompanyname.DataBindings.Add("Text", dv1, "CompanyName")
txtContactname.DataBindings.Add("Text", dv1, "ContactName")
txtPostalcode.DataBindings.Add("Text", dv1, "PostalCode")
'textboxen databinding 'Orders-table'
txtOrderId.DataBindings.Add("Text", dv1, "relCustomersOrders.OrderId")
txtShipCity.DataBindings.Add("Text", dv1, "relCustomersOrders.ShipCity")
txtShipCountry.DataBindings.Add("Text", dv1,
"relCustomersOrders.ShipCountry")
*** END CODEEXAMPLE ***