none
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.

    https://www.dotnetspider.com/resources/28676-Populate-TreeView-From-DataBase-Using-Recursive.aspx

    Thursday, December 19, 2019 8:47 PM

Answers

All replies

  • Hi,

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

    https://social.msdn.microsoft.com/Forums/en-US/83af9e2c-92f5-45e2-8517-fc034296088a/how-to-save-text-of-parent-and-child-treeview-nodes-into-sql-2008-db-using-vbnet?forum=vbgeneral

    Hope it be helpful.

    Best Regards,

    Julie


    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 MSDNFSF@microsoft.com.

    • Marked as answer by JMANCI Friday, December 20, 2019 4:03 PM
    Friday, December 20, 2019 7:23 AM
    Moderator
  • 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
                PrintRecursive(aNode)
            Next
        End Sub




    Friday, December 20, 2019 4:03 PM