VB.Net GetChildRows command ?

Posted on 2007-07-30
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

    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

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now