Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / July 2003

Tip: Looking for answers? Try searching our database.

Navigation of typed dataset in many-to-many relationships

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas Zaleski - 11 Jul 2003 22:58 GMT
I have 5 tables in my dataset that I have pulled all records for from
the database. The table structure look like this:

Products(productid, productname)
Product2Category(productid, categoryid)
Category(categoryid, categoryname)
Product2Genre(productid, genreid)
Genre(genreid, genre name)

So basically, when someone clicks on a category, i.e. categoryid = 5,
then I would like to pull all associated genres (DISTINCT) for the
products corresponding to category id = 5.

How would I navigate and pull that data.

Please let me know.

Thanks.
Mikael Gustavsson - 28 Jul 2003 09:15 GMT
Hi Thomas!

If you have created a relation between for instance the Products table and
the Products2Genre tables and that in time to the Genre table then you can
just walk down the hierarchy.

//This will symbolize the fetching of the products
ProductDataSet ds = GetTheProducts();

string categoryName =
ds.Products[x].GetProduct2GenreRows()[y].GetGenreRows()[z].genrename

So in your case you could do it this way

foreach (ProductDataSet.Product2Genre productGen in
ds.Procducts[5].GetProduct2GenreRows())
{
   foreach (ProductDataSet.Genre gen in productGen.GetGenreRows())
   {
       //Do what you want to do with the genre here
   }
}

Well, I hope this helps you out a bit in the right direction

//Mikael

> I have 5 tables in my dataset that I have pulled all records for from
> the database. The table structure look like this:
[quoted text clipped - 14 lines]
>
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.