Home All Groups Group Topic Archive Search About

How select from 2 ADO.NET DataTables?

Author
10 Mar 2006 5:30 AM
Ronald S. Cook
Let's say I have 2 ADO.NET DataTables (tblAuthor and tblBook) within an
ADO.NET DataSet (dstPublish).



tblAuthor has DataColumns AuthorID and AuthorName,  tblBook has DataColumns
BookID, BookTitle, AuthorID (assume a book can be written by only one
author).



tblAuthor

---------

1 Ayn

2 Jim

3 Sue



tblBook

-------

10 Fountainhead 1

11 Atlas Shrugged 1

12 Moby Dick 2



I want to create a list of all books with their associated author name.



FountainHead Ayn

Atlas Shrugged Ayn

Moby Dick



This is a breeze in SQL for me, but I'm not sure how to go about using
ADO.NET DataTables.  Do I need a DataRelation, or is it just a matter of
having a for loop within a for loop, or is it something else?



Thanks,

Ron

Author
10 Mar 2006 6:30 AM
Cor Ligthert [MVP]
Ronald,

If there is a relation set, than you can use the childrows from the
tblAuthor

If there is no relation set, than you can set the AuthorID as a rowfilter in
the tblBook.defaultview (an inbuild dataview)

As well you can use the TableSelect with an expression.

The less work is that dataview method.

I hope this helps,

Cor

Show quoteHide quote
"Ronald S. Cook" <rc***@westinis.com> schreef in bericht
news:ei5zPPARGHA.2436@TK2MSFTNGP11.phx.gbl...
> Let's say I have 2 ADO.NET DataTables (tblAuthor and tblBook) within an
> ADO.NET DataSet (dstPublish).
>
>
>
> tblAuthor has DataColumns AuthorID and AuthorName,  tblBook has
> DataColumns BookID, BookTitle, AuthorID (assume a book can be written by
> only one author).
>
>
>
> tblAuthor
>
> ---------
>
> 1 Ayn
>
> 2 Jim
>
> 3 Sue
>
>
>
> tblBook
>
> -------
>
> 10 Fountainhead 1
>
> 11 Atlas Shrugged 1
>
> 12 Moby Dick 2
>
>
>
> I want to create a list of all books with their associated author name.
>
>
>
> FountainHead Ayn
>
> Atlas Shrugged Ayn
>
> Moby Dick
>
>
>
> This is a breeze in SQL for me, but I'm not sure how to go about using
> ADO.NET DataTables.  Do I need a DataRelation, or is it just a matter of
> having a for loop within a for loop, or is it something else?
>
>
>
> Thanks,
>
> Ron
>
>