Save Treeview to SQL Database RRS feed

  • Question

  • I'm trying to convert my existing VB6 Treeview code to the .NET Windows Forms Treeview. I was able to convert existing code to load the Treeview correctly from a SQL database using recursion. The example in the below link helped me. But now I'm trying to find an example where I can save the changes back to SQL and not finding anything useful. Can someone point me in the right direction? I also attached what my 1 table and underlying data looks like.

    Thursday, December 19, 2019 8:47 PM


All replies

  • Hi,

    Someone encountered similar question, you can check in the following link for more details which is written in VB.NET.

    Hope it be helpful.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by JMANCI Friday, December 20, 2019 4:03 PM
    Friday, December 20, 2019 7:23 AM
  • That worked, thanks. I'll post my working code here.

    Call CallRecursive(TreeView1)

    Private Sub CallRecursive(ByVal aTreeView As TreeView) Dim n As TreeNode For Each n In aTreeView.Nodes 'Call Insert of Parent here - ChildOf is always 0_ for a parent Call siEPsLtrs(Replace(n.Name, "_", ""), "0_", n.Text, "0") 'Now go get all of the children for this parent node PrintRecursive(n) Next End Sub
        Private Sub PrintRecursive(ByVal n As TreeNode)
            Dim aNode As TreeNode
            For Each aNode In n.Nodes
                'Call Insert of Child here
                Call siEPsLtrs(aNode.Name, Replace(n.Name, "_", ""), aNode.Text, aNode.Tag)
                'Get next child
        End Sub

    Friday, December 20, 2019 4:03 PM