473,385 Members | 1,620 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,385 software developers and data experts.

Navigating parent-child relation to update the child records --- How???

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 (ds), have 2 datatables (dtRC and dtST). Created the parent-child relationship with multiple columns and added the
relation to the dataset.

Now what I want is to move through each of the dtRC (parent) records, get all related dtST (child) records and update the child records with data from
the parent. In the code below RCCount is the number of parent records that are in dtRC.

After running the code it goes thru each parent and EVERY child for each parent. Have to limit the children for each parent.

How do I know how many children the parent has? I know I have to put the Update and AcceptChanges in after this update.

What am I missing in this puzzle?

I know there is an easy way to do this. I just don't know it yet. Got a lot of Googling to do, but can you help me on this one now?

Thanks,

Hexman

==================================================
Private Sub Process1()
Dim Idx As Integer
Dim Idx2 As Integer

' Define the relationship between the tables.
Dim parentColumn() As DataColumn
parentColumn = New DataColumn() {dtRC.Columns("RCDate"), dtRC.Columns("RCItem"), dtRC.Columns("RCMfgNum")}
Dim childColumn() As DataColumn
childColumn = New DataColumn() {dtST.Columns("STDate"), dtST.Columns("STItem"), dtST.Columns("STMfgNum")}
Dim dRelRCST As DataRelation
dRelRCST = New DataRelation("RC-ST", parentColumn, childColumn)
' Add the relation to the DataSet
ds.Relations.Add(dRelRCST)

For Idx = 0 To RCCount - 1
For Idx2 = 0 To ????????
dtST.Rows(Idx2).Item("STPriVend") = dtRC.Rows(Idx).Item("RCPriVend")
Next
Next
End Sub
Oct 5 '06 #1
1 2746
I think I've found it!!!

Dim drRC As DataRow
Dim drST As DataRow
For Each drRC In dtRC.Rows
For Each drST In drRC.GetChildRows(dRelRCST)
drST.Item("STPriVend") = drRC.Item("RCPriVend")
Next
Next

While I'm here can anyone enhance my code below or the code above?

Hexman

On Thu, 05 Oct 2006 00:49:25 -0700, Hexman <He****@binary.comwrote:
>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 (ds), have 2 datatables (dtRC and dtST). Created the parent-child relationship with multiple columns and added the
relation to the dataset.

Now what I want is to move through each of the dtRC (parent) records, get all related dtST (child) records and update the child records with data from
the parent. In the code below RCCount is the number of parent records that are in dtRC.

After running the code it goes thru each parent and EVERY child for each parent. Have to limit the children for each parent.

How do I know how many children the parent has? I know I have to put the Update and AcceptChanges in after this update.

What am I missing in this puzzle?

I know there is an easy way to do this. I just don't know it yet. Got a lot of Googling to do, but can you help me on this one now?

Thanks,

Hexman

================================================= =
Private Sub Process1()
Dim Idx As Integer
Dim Idx2 As Integer

' Define the relationship between the tables.
Dim parentColumn() As DataColumn
parentColumn = New DataColumn() {dtRC.Columns("RCDate"), dtRC.Columns("RCItem"), dtRC.Columns("RCMfgNum")}
Dim childColumn() As DataColumn
childColumn = New DataColumn() {dtST.Columns("STDate"), dtST.Columns("STItem"), dtST.Columns("STMfgNum")}
Dim dRelRCST As DataRelation
dRelRCST = New DataRelation("RC-ST", parentColumn, childColumn)
' Add the relation to the DataSet
ds.Relations.Add(dRelRCST)

For Idx = 0 To RCCount - 1
For Idx2 = 0 To ????????
dtST.Rows(Idx2).Item("STPriVend") = dtRC.Rows(Idx).Item("RCPriVend")
Next
Next
End Sub
Oct 5 '06 #2

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

Similar topics

5
by: skip | last post by:
A simple script like the one below lets me jump through a directory structure. However, if I run it from /this/directory and within it to go to /a/totally/different/directory... I'm still...
1
by: rbowie | last post by:
Hi there im tryin to nav to a frame using javascript. I have a frameset within a frameset. I want to be able to navigate from the inner most frameset to an outer frame. So frame i have only...
3
by: Adrian | last post by:
Hi All, I load an Iframe within html page contained within another page and from the hosting page I would like to scroll to a given bookmark within the page loaded within the iframe without...
3
by: Paul Neave | last post by:
Yahoo! has launched a beta of it's new mapping application: http://maps.yahoo.com/beta/ It's based in Flash, but it uses JavaScript. I'm curious about one feature, though - when you pan about...
4
by: jenyb via DotNetMonster.com | last post by:
Hi , I use VB.net to work with XML database,I need to use a DocumentNavigator class to navigate in XML document, I need to use MoveToChild/MoveToParent there the problem is that i don't know how...
1
by: sympatico | last post by:
Hi, We are working on a .NET application. In our project, most of the interfaces use frames. We have a problem accessing previous page using frames. Let us say we have a page A that does not...
3
by: BobAchgill | last post by:
Is this the right way to get to back up to the immediate parent subdirectory? Directory.GetParent("\") or this? Directory.GetParent("..") Or this?
1
by: JohnMOsborn | last post by:
I am designing an Access database that will use tab controls. Normally, you place different sets of fields on each page of the tab control – like Fields1-3 on Page 1, Fields 4-6 on Page 2, etc. In...
0
by: in10se | last post by:
I have a .NET 2.0 application that uses the WebBrowser control. Because all of my pages are generated dynamically, I am catching the Navigating event, cancelling it, and performing my own operations...
3
by: msaccessprogrammer | last post by:
I have a form and a subform on two separate pages in a tab. I would like that when the user finishes inserting the information in the subform, he will get to a combo box in the bottom of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.