Iterating through a datarelation's rows

  • Thread starter Thread starter Brian Link
  • Start date Start date
B

Brian Link

This is what I get for trying to do things the ADO.NET way instead of
using plain ol ADO..

Anyway, I have two related tables. I've finally hooked em up so that
they're in synch, but now I need to be able to iterate through the
child table's rows, and I can't figure out how.

For instance, with a single table I can do thus (adding rows to a
treeview):


For i = 0 To DsEnt1.R_Relations.Count - 1
nd = tvClient.Nodes.Add(DsEnt1.R_Relations(i).Name_Last)
Next

But If there is a datarelation named "E_ClientR_Relations" in my
E_Client table, how come I can't do:

For i = 0 to DsEnt1.E_Client.E_ClientR_Relations.Count - 1
....

I can't seem to find the relation anywhere enumerated so I can loop
through it.

Brian Link, Minnesota Countertenor
 
This is what I get for trying to do things the ADO.NET way instead of
using plain ol ADO..

Anyway, I have two related tables. I've finally hooked em up so that
they're in synch, but now I need to be able to iterate through the
child table's rows, and I can't figure out how.

For instance, with a single table I can do thus (adding rows to a
treeview):


For i = 0 To DsEnt1.R_Relations.Count - 1
nd = tvClient.Nodes.Add(DsEnt1.R_Relations(i).Name_Last)
Next

But If there is a datarelation named "E_ClientR_Relations" in my
E_Client table, how come I can't do:

For i = 0 to DsEnt1.E_Client.E_ClientR_Relations.Count - 1
...

I can't seem to find the relation anywhere enumerated so I can loop
through it.

Brian Link, Minnesota Countertenor

Okay, never mind. I just found it.

Apparently I need to dimension a DataRow array, then assign it to the
child table using the "GetChildRows" function. I.E.:

Dim oRow() As DataRow _
= DsEnt1.Tables("E_Client").Rows(0).GetChildRows("E_ClientR_Relation")

That seems a little like old-fashioned datashaping.. you'd have
thought in the ADO upgrade they would have made the child table
directly addressible when using a typed dataset. Oh well.

BLink
 
Back
Top