473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to update databound textboxes in parent child datarelation

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 ***
Nov 21 '05 #1
0 1364

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pesko S | last post by:
Hi, Could anybody just point me in a direction where I can find information on how the heck I can update a database with relational data from an XML file. I use stored procedures to insert...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
1
by: Matt | last post by:
I recently came across what I believe to be a peculiar bug with Mdi Children, and wanted to see if anyone else had experienced this before sending it in. The issue is as follows: I have a number...
1
by: Jan Lorenz | last post by:
Hello, my problem is to show a datarelation between two tables (parent/child) in a datagridview. It doesn't works. There is always shown only 1 table in the grid (in relation of...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
4
by: mikemiller.innova | last post by:
In Visual Studio 2005 SP1, I added a DataSet item into my project. I added 3 tables from SQL that have data and relationships. I added 2 lookup columns (lkp) to the DllVersions table in the...
6
by: | last post by:
Hi, I'm steel trying to read and update my XML file with Visual Basic Express but i am unable to find the right way to read my xml file and update it if neccessary... Here is my problem :...
1
by: Bob Johnson | last post by:
..NET 3.5, Windows Forms app: My objective is to display parent/child data in two ComboBox controls, such that when a parent item is selected in one combo box, associated child items appear in the...
1
by: Sep410 | last post by:
Private Sub frmSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sql1 As String Dim sql2 As String Dim da1 As SqlDataAdapter ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.