473,659 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("R CItem"), dtRC.Columns("R CMfgNum")}
Dim childColumn() As DataColumn
childColumn = New DataColumn() {dtST.Columns(" STDate"), dtST.Columns("S TItem"), dtST.Columns("S TMfgNum")}
Dim dRelRCST As DataRelation
dRelRCST = New DataRelation("R C-ST", parentColumn, childColumn)
' Add the relation to the DataSet
ds.Relations.Ad d(dRelRCST)

For Idx = 0 To RCCount - 1
For Idx2 = 0 To ????????
dtST.Rows(Idx2) .Item("STPriVen d") = dtRC.Rows(Idx). Item("RCPriVend ")
Next
Next
End Sub
Oct 5 '06 #1
1 2767
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.GetChildRo ws(dRelRCST)
drST.Item("STPr iVend") = drRC.Item("RCPr iVend")
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("R CItem"), dtRC.Columns("R CMfgNum")}
Dim childColumn() As DataColumn
childColumn = New DataColumn() {dtST.Columns(" STDate"), dtST.Columns("S TItem"), dtST.Columns("S TMfgNum")}
Dim dRelRCST As DataRelation
dRelRCST = New DataRelation("R C-ST", parentColumn, childColumn)
' Add the relation to the DataSet
ds.Relations.Ad d(dRelRCST)

For Idx = 0 To RCCount - 1
For Idx2 = 0 To ????????
dtST.Rows(Idx2) .Item("STPriVen d") = 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
3264
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 actually going to be in /this/directory when I exit the script. Is it possible to have a script that can drop me off into a different directory than where I initiated it from? import os process = 1 while (process):
1
2183
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 managed to nav to a frame within the current framset using the following code:
3
5652
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 causing it to reload. How do I do this?
3
31933
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 the map, the URL in the address bar of your browser changes to match your current location. How have they done this? I thought calling window.location.href = "etc"; would reload the page, navigating away from the current URL. Yahoo! have...
4
1742
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 to load this DocumentNavigator. (when I write the Imports ... it doesn't recognize it ) tnx for advance.
1
1220
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 use any frames. Then from this page, say control goes to Page B that has two frames. On the right frame, I have some data capture fields. When the user makes some data entry and then decides to 'Cancel' out of the page, the control is moving back...
3
1363
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
3445
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 my database, however, I want to associate a particular numbered record of a field with each separate tab. In exploring my options, it looks like the best way to do this is to add a record-navigating “On Click” event to each separate page of the...
0
1909
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 based on the Uri that is passed in the WebBrowserNavigatingEventArgs.Url property. If the page is requesting an external URL, I would like to open the page in a new browser window. When requesting an external page, the URL is of the form:...
3
1934
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 subform and will have two options to choose from: 1. Add another record to the subform. 2. Return to the parent form in the current parent record. The options will be executed by a command next to the combo. Thanks.
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8751
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.