Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.aspnet.webservices
Navigation of typed dataset in many-to-many relationships
Shawn Jackson
7/11/2003 9:58:00 PM
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.
*** Sent via Developersdex
http://www.develop...
***
Don't just participate in USENET...get rewarded for it!
1 Answer
Mikael Gustavsson
7/28/2003 8:16:00 AM
0
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
"Thomas Zaleski" <anonymous@devdex.com> wrote in message
news:Oa$zCe$RDHA.1552@TK2MSFTNGP10.phx.gbl...
> 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.
>
> *** Sent via Developersdex
http://www.develop...
***
> Don't just participate in USENET...get rewarded for it!
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Navigation of typed dataset in many-to-many relationships
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password