Traverse the Many-to-Many relationship?

G

Guest

I have two tables in an Access database with a Many-to-Many relationship,
there is a connection table. The tables are [Product Line], [Factors], and
the connection table is [Product Line performance Factors] this is a standard
Many-to-Many relationship in that the connect table only has two foreign key
columns one for each of the other table primary keys, a very straightforward
setup.

The above is setup in a data set in a Data Set called “ProductDataSet†in a
C# program. I have a record (row) in the [Product Line]. See code below:
ProductDataSet.ProductLineRow productLineRow;
productLineRow =
(ProductDataSet.ProductLineRow)modelRow.GetParentRow("Product LineModel");
The “modelRow†I from a parent table to the product table that the row was
choose through a control.

The question is how do I get the set of rows form the [Factors] table
knowing the row for the [Product Lint] table; how do I traverse the
relationship? There is a method attached to the [Product Line] table row
called:
productLineRow.GetProduct_Line_performance_FactorsRows()
I tried to use it as such:
ProductDataSet.FactorsDataTable [] factorsTable;
factorsTable =
(ProductDataSet.FactorsDataTable)productLineRow.GetProduct_Line_performance_FactorsRows();
However, this is not working it seams to want to return an array. An array
of what?

This is should be a straightforward operation that is easily accomplished in
SQL.
PARAMETERS ProductLineID Long;
SELECT [Product Line].[Product Line ID], Factors.[Factors Name],
Factors.[Factor Coefficent A0], Factors.[Factor Coefficent A1],
Factors.[Factor Coefficent A2]
FROM [Product Line] INNER JOIN (Factors INNER JOIN [Product Line performance
Factors] ON Factors.[Factors ID] = [Product Line performance
Factors].[Factors ID]) ON [Product Line].[Product Line ID] = [Product Line
performance Factors].[Product Line ID]
WHERE ((([Product Line].[Product Line ID])=[ProductLineID]));

I have on row in on table I should be able to easily get a table back of the
rows that it refers to. Do I have to revert to a separate quire to perform
this operation?
Thank you,
 
B

Bob Barrows [MVP]

Michael said:
I have two tables in an Access database with a Many-to-Many
relationship,
there is a connection table. The tables are [Product Line],
[Factors], and
the connection table is [Product Line performance Factors] this is a
standard Many-to-Many relationship in that the connect table only has
two foreign key
columns one for each of the other table primary keys, a very
straightforward
setup.

The above is setup in a data set in a Data Set called


Oops, time for my standard "dotnet" reply:
There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended
practice) , but this is a classic ADO newsgroup. ADO.Net bears very little
resemblance to classic ADO so,
while you may be lucky enough to find a dotnet-knowledgeable person here who
can answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.adonet.

Oh wait, this is a crosspost ... well, you've included two irrelevant
newsgroups in your crosspost list. I encountered this post in .data.ado,
which again, is a classic ADO group. The other irrelevant group is the
vb.database group, which again, has nothing to do with .Net. Best practice
is to limit your post to a single newsgroup (the csharp group was definitely
relevant, and you will probably get good help there) ... if you mistakenly
pick an irrelevant group, someone will steer you in the right direction
(politely, I hope).
rows that it refers to. Do I have to revert to a separate quire to
perform
this operation?

That would be my preferred way of doing it, but perhaps the dotnet guys can
steer you to a builtin way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top