Dataset Relations in Code

  • Thread starter Thread starter Cdudej
  • Start date Start date
C

Cdudej

Is the a way that is can do this but through 3 table

I have User - Statuslink - Status i need to link these together then i
want to add them to the treeview.

ds.Relations.Add("AuthorTitle",
ds.Tables["Authors"].Columns["au_id"],
ds.Tables["Titles"].Columns["au_id"]);

//Populate the TreeView from the DataSet.
foreach (DataRow rowAuthor in ds.Tables["Authors"].Rows)
{
nodeAuthor = new TreeNode();
nodeAuthor.Text = rowAuthor["au_lname"] + ", "
+ rowAuthor["au_fname"];
TreeView1.Nodes.Add(nodeAuthor);
foreach (DataRow rowTitle in

rowAuthor.GetChildRows("AuthorTitle"))
{
nodeTitle = new TreeNode();
nodeTitle.Text = rowTitle["Title"].ToString();
nodeAuthor.Nodes.Add(nodeTitle);
}
 
Cdudej said:
Is the a way that is can do this but through 3 table

I have User - Statuslink - Status i need to link these together then i
want to add them to the treeview.

ds.Relations.Add("AuthorTitle",
ds.Tables["Authors"].Columns["au_id"],
ds.Tables["Titles"].Columns["au_id"]);

You add 3 tables, then 2 relations like you do there.
Then you do a foreach within a foreach within a foreach.
Which bit don't you get?
 
Back
Top