many-to-many w/ DataRelations

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi-

I'm still trying to put DataRelations to good and proper use on our site.
So far I'm having a hard time. Here is my situation:

Tbl_Products
[ id ]

Tbl_Prod_Faqs (many to many)
[ prodid ] [ faqid ]

Tbl_Faqs
[ faqid ] [ question ] [ answer ]


so, I want to get all the faqs for a given product or better yet, bind a
DataList to the Tbl_Products then a nested DataGrid and use "GetChildRows()"
to get the faq data
Tbl_Prod_Faqs is my many-to-many table where I relate the FAQs to their
respective Products

What is the correct way to setup DataRelation objects so that I can use this
data in a way that is best? So far I've managed to accomplish this:
DataRelation relFaq2Prod = new DataRelation("relFaq2Prod",
ds.Tables["Tbl_Products"].Columns["id"],
ds.Tables["Tbl_Products"].Columns["id"]);

DataSet dsFaq = NSDal.CNSDal.GetSupportFaqs2();
DataRow[] rows =
dsFaq.Tables["Tbl_Products"].Rows[0].GetChildRows(dsFaq.Relations[0]);

I can then bind the rows DataRow array to the DataGrid(which it doesn't like
at all, shows me "Has Errors")

I'm not seeing how I can utilize DataRelations to get what I need?

Hopefully someone will be able to make sense of this.

Thanks for reading,
Steve
 
from MSDN
"Because the dataset can hold multiple, separate tables and maintain
information about relationships between them, it can hold much richer data
structures than a recordset, including self-relating tables and tables with
many-to-many relationships."

I can't find a working example of this anywhere though.... it seems that
this would be a common task
 
Back
Top