VB.Net GetChildRows command ?

Posted on 2007-07-30
Medium Priority
Last Modified: 2009-12-16

I'm using the following code to retrieve Child rows from a VB.Net DataRelation.

drVendorsMain = New DataRelation("drVendorsMain", dsMRP.Tables("Material").Columns("Material"), dsMRP.Tables("Vendor_Material").Columns("Material"), False)

What I'm trying to do is loop through multiple rows that may be returned by the GetChildRows command.  Here's my code that collects the value from one row, but I need to retrieve multiple rows one at a time in certain cases.  Please help.

Dim dRows() As System.Data.DataRow = dsMRP.Tables("Material").Rows(i).GetChildRows("drVendorsMain")
If dRows.GetLength(0) > 0 Then
      BackupVendor = dRows(0).Item("Backup_Vendor")
End If

Question by:JMO9966
LVL 24

Accepted Solution

mankowitz earned 500 total points
ID: 19597664
Dim dRows() As System.Data.DataRow = dsMRP.Tables("Material").Rows(i).GetChildRows("drVendorsMain")
If dRows.GetLength(0) > 0 Then
    for k as integer=0 to drows.getlength(0)-1
      BackupVendor = dRows(k).Item("Backup_Vendor")
     'Now do something with BackupVendor
    next k
End If
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 500 total points
ID: 19598760

Imports System.Data


Dim dtMaterial As DataTable = dsMRP.Tables("Material")
For Each parentRow As DataRow in dtMaterials.Rows
     For Each childRow As DataRow in parentRow.GetChildRows("drVendorsMain")
        Dim backupVendor As String = childRow("Backup_Vendor").ToString()
    Next childRow
Next parentRow


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question