Add a child node to a tree in vb.net

I need to bind datype to dacontent by the lngIntakeID and then display it under node prod the structure should be
>Create new client Contact
>Date
  --->   intake date- staff - dob  
         ----->  data for that intake

I can get the queries to work but I'm not sure how to modify the code to get the node type tolink.  Thanks
Dim daSections As New SqlDataAdapter("SELECT DISTINCT TOP 100 PERCENT convert(varchar(10),dbo.tblMHCIntake.dtmIntake,101) as intakedate,dtmintake, DATENAME(dw, dbo.tblMHCIntake.dtmIntake) AS dayname FROM         dbo.tblMHCIntake   where dtmintake > '01/01/2008'ORDER BY dbo.tblMHCIntake.dtmIntake DESC", Connection1)
        Dim daContent As New SqlDataAdapter("SELECT DISTINCT TOP 100 PERCENT tblPatient.strLName + ', ' + tblPatient.strFName AS name, CONVERT(varchar(10), tblMHCIntake.dtmIntake, 101) AS intakedate, tblMHCIntake.dtmIntake, tblMHCIntake.strStaff, CONVERT(varchar(10), tblPatient.dtmDOB, 101) AS dtmdob, tblPatient.strPatientId, tblMHCIntakeDetail.lngIntakeId FROM tblMHCIntake INNER JOIN tblMHCIntakeDetail ON tblMHCIntake.lngIntakeId = tblMHCIntakeDetail.lngIntakeId INNER JOIN tblLUMHCData ON tblMHCIntakeDetail.lngDataId = tblLUMHCData.lngDataID RIGHT OUTER JOIN tblPatient ON tblMHCIntake.lngPatientId = tblPatient.lngPatientId WHERE (tblMHCIntake.dtmIntake > '1/1/2008')ORDER BY tblMHCIntake.dtmIntake DESC", Connection1)
               Dim datype As New SqlDataAdapter("SELECT DISTINCT TOP 100 PERCENT tblMHCIntakeDetail.lngIntakeId , tblMHCIntakeDetail.lngDataId, tblLUMHCData.strData FROM tblMHCIntake INNER JOIN tblMHCIntakeDetail ON tblMHCIntake.lngIntakeId = tblMHCIntakeDetail.lngIntakeId INNER JOIN tblLUMHCData ON tblMHCIntakeDetail.lngDataId = tblLUMHCData.lngDataID RIGHT OUTER JOIN tblPatient ON tblMHCIntake.lngPatientId = tblPatient.lngPatientId WHERE (tblMHCIntake.dtmIntake > '1/1/2008')ORDER BY tblMHCIntake.dtmIntake DESC", Connection1)

        daSections.Fill(objDS, "dtSections")
        daContent.Fill(objDS, "dtContent")
        '    datype.Fill(objDS, "dtType")

        objDS.Relations.Add("SectionToContent", _
        objDS.Tables("dtSections").Columns("dtmIntake"), _
        objDS.Tables("dtContent").Columns("dtmIntake"))



        nodenew = New TreeNode
        nodenew.Text = "Create new Client Contact..."
        TreeView1.Nodes.Add(nodenew)
        For Each rowSupp In objDS.Tables("dtSections").Rows
         
            nodeSupp = New TreeNode
            nodeSupp.Text = rowSupp("dtmIntake")

            TreeView1.Nodes.Add(nodeSupp)
            For Each rowProd In rowSupp.GetChildRows("SectionToContent")
                nodeProd = New TreeNode
                nodeProd.Text = rowProd("intakedate") & " - " & rowProd("strStaff") & " - " & rowProd("name") & " - " & rowProd("dtmdob") & " - " & rowProd("strPatientid")
                'need to databind rowProd ("lngIntakeId")  
                nodeProd.Tag = rowProd("lngIntakeID")
                ' nodetype = New TreeNode
                '  nodetype.Text = rowProd("strdata")
                'need to databind rowProd ("lngIntakeId")  

                nodeSupp.Nodes.Add(nodeProd)
                '  nodeProd.Nodes.Add(nodetype)
            Next

        Next

Open in new window

running32Asked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
You need to modify the loop which is populating the nodes to add subnodes.
0
 
CodeCruiserCommented:
Try rephrasing the problem.
0
 
running32Author Commented:
Ok, I need to create a tree view.

Node  - Create new client contact
Node  - Intake date ( from sql query daSections)
child Node -   Information on Intake ( from sql query daContent)
     child Node  - Information on type of intake ( from sql query datype)

I can get it to work linking the dates and so when the tree opens there is client information under the intake date, what I need now is to add under the client information another child which has the type.  It needs to be linked to the client information not the date.

Does this make or sense?

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
CodeCruiserCommented:
No. Try adding some example with data.

>Node  - Create new client contact
You create a new client root node in code? All child nodes are populated from db right?

0
 
running32Author Commented:

One of the roots is created by code the other (the date) is created by populating it from the db.
both chld notes are created by populating from db.
>  Create New Client
>  3/30/2010
    >   Jane Smith - 1/1/2010 -
         >  Intake      
> 3/29/2010
    >   John Smiht - 3/3/1198-
        >  Consult
    >  Test Person - 1/1/2000
        >   Intake
> 3/29/2010
    > Another Person 9/9/1999
         > Walk-in  
     

0
 
CodeCruiserCommented:
Ok. Now what node do you need to add? Another like this

> 3/29/2010
    > Another Person 9/9/1999
         > Walk-in

???
0
 
running32Author Commented:
I need to add the > Walk-in node.  I can't figure out the code to get it to display under the >Another Person 9/9/1999.

The > Walk-in node should be tied to datype.Fill(objDS, "dtType")

Thanks
0
 
running32Author Commented:
go it, thanks

 For Each rowSupp In objDS.Tables("dtSections").Rows

            nodeSupp = New TreeNode
            nodeSupp.Text = rowSupp("dtmIntake")

            TreeView1.Nodes.Add(nodeSupp)
            For Each rowProd In rowSupp.GetChildRows("SectionToContent")
                nodeProd = New TreeNode
                nodeProd.Text = rowProd("intakedate") & " - " & rowProd("strStaff") & " - " & rowProd("name") & " - " & rowProd("dtmdob") & " - " & rowProd("strPatientid")
                nodeProd.Tag = rowProd("lngIntakeID")
                nodeSupp.Nodes.Add(nodeProd)
                For Each rowType In rowProd.GetChildRows("SectionToType")
                    nodetype = New TreeNode
                    nodetype.Text = rowType("strData")
                    nodeProd.Nodes.Add(nodetype)
                Next

            Next

        Next
0
 
CodeCruiserCommented:
Glad you got it working :-)
0
All Courses

From novice to tech pro — start learning today.