Syntax for using data relations

I've got a data set with two tables and a one to many relationship between them, all generated in the VS2005 Dataset designer.  In the vb code, I can access the tables and their adapters fine.

I'd like to get the child rows associated with a parent row, and then total values in the child row.  But first thing first, just get the collection of child rows.

In my newbie-ness, I got as far as this:  
 
Dim wrkRows As DataRowCollection
        wrkRows = wrkTable.FindByID(wrkID).GetChildRows(            <-- asks for name of datarelation here

but I don't know how to call up the name of the data relation that apparently is supposed to go into the parameters for the .GetChildRows method.   It doesn't seem to come up through intellisense if I type in the name of the dataset there.

Am I supposed to type the name in without the intellisense?  Is the name in the intellisense for the dataset, but under another variable?  Should it be there, and because it's not it indicates I've not completed the relation properly?  Am I approaching this whole thing incorrectly?

Any guidance on this would be appreciated.

Thanks!
LVL 2
codequestAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Did you define a DataRelation for the DataSet?

Example:

  Dim table1 As DataTable = ds.Tables("Table1")
  Dim table2 As DataTable = ds.Tables("Table2")
  ds.Relations.Add("Table1_Table2", table1.Columns("PrimaryKey"), table2.Columns("PrimaryKey"))

Bob
0
codequestAuthor Commented:
Thanks for the input.  Well, I built the relation in the XML Schema designer for the dataset.  I'll try building it in code per your example and see what shows up...it's there when I go back and look at it.  I'm surprised the schema designer didn't add it to the ds.Relations collection...any clue as to whether it was supposed to?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Bob LearnedCommented:
In the schema designer, is there a relationship defined between the tables?

Bob
0
codequestAuthor Commented:
navstar16:  thanks, those are useful.

Bob:  Yes, there appears to be.  In the Dataset designer there's an arrow between the two tables.  When I select Edit on the arrow it shows the configuration box for the relation...I'm a newbie in SQL but know some Access and it all looks normal.   There's XML in the schema file (which I'm unfamiliar with) that seems to have enough info to represent the relation...and the same name that's shown in the designer for the relation.
 

0
Bob LearnedCommented:
How are you filling the DataSet?

Bob
0
codequestAuthor Commented:
Both tables are filled using tableadapters.
0
Bob LearnedCommented:
What is the result of DataSet.Relations.Count then?

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
codequestAuthor Commented:
Count = 1

So perhaps I just need the right syntax.
0
codequestAuthor Commented:
Which I think I figured out...and am now testing....

I guess I was looking for intellisense access to the relations by name, which I couldn't find.  Settling for access by literal or index number.
0
codequestAuthor Commented:
Yep, works, so I'll split points here.  Thanks for the prompting and coaching!
0
codequestAuthor Commented:
Key to syntax was realizing that      parentrow.childrelations(relation)   returns an array of rows, not a collection
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.