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.