Vb.net 到树视图的级别

Vb.net 到树视图的级别,vb.net,treeview,Vb.net,Treeview,嘿,我有一个树状视图的问题,我不能正常工作,我试图有三个级别的it InspectorName,InspectionDate和AddressLine1 我是从存储过程调用信息的,但是我看不到它能起作用。我只是在第一级,我很确定我的代码可能有点不对劲 Sub LoadInspectionTree() '**Loads Property List ' Initialise Error Checking ' Dimension Local Variables D

嘿,我有一个树状视图的问题,我不能正常工作,我试图有三个级别的it InspectorName,InspectionDate和AddressLine1

我是从存储过程调用信息的,但是我看不到它能起作用。我只是在第一级,我很确定我的代码可能有点不对劲

  Sub LoadInspectionTree()
    '**Loads Property List
    ' Initialise Error Checking


    ' Dimension Local Variables
    Dim uRecSnap As ADODB.Recordset
    Dim uPar As ADODB.Parameter
    Dim uNode As TreeNode
    Dim aNode As TreeNode
    Dim iInspectorID As Integer = 0
    Dim iInspectorcnt As Integer = 0
    Dim iInspectionID As Integer = 0
    Dim iInspectionIDcnt As Integer = 0

    Dim uStackframe As New Diagnostics.StackFrame
    Try

        ' Check For Open Connection
        If uDBase Is Nothing Then
            OpenConnection()
            bConnection = True
        End If

        ' Run Stored Procedure - Load Property List (Based on Search Value)
        uCommand = New ADODB.Command
        With uCommand
            .ActiveConnection = uDBase
            .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
            .CommandTimeout = 0
            uPar = .CreateParameter("@SearchValue", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
            .Parameters.Append(uPar)
            .Parameters("@SearchValue").Value = txtFilter.Text
            .CommandText = "Inspections_LoadRecords"
            uRecSnap = .Execute
        End With


        ' Suppress TreeView Repaint / Clear TreeView
        tgvInspections.BeginUpdate()
        tgvInspections.Nodes.Clear()
        tgvInspections.ShowNodeToolTips = True

        ' Populate List


        Do Until uRecSnap.EOF

            If iInspectorId <> uRecSnap("InspectorID").Value Then
                uNode = tgvInspections.Nodes.Add("G" & Format(uRecSnap("InspectorID").Value, "0000"), uRecSnap("InspectorName").Value)
                uNode.Tag = "G:" & Format(uRecSnap("InspectorID").Value, "0000") & ":0000"
                iInspectorId = uRecSnap("InspectorID").Value
                iInspectorcnt = iInspectorId + 1
            End If

            If (IsDBNull(uRecSnap("InspectionID").Value)) = False Then
                If iInspectionID <> uRecSnap("InspectionID").Value Then
                    uNode = tgvInspections.Nodes(iInspectorID - 1).Nodes.Add("I" & Format(uRecSnap("InspectionID").Value, "00"), uRecSnap("InspectionDate").Value)
                    uNode.Tag = "I:" & Format(uRecSnap("InspectorID").Value, "0000") & ":" & Format(uRecSnap("InspectionID").Value, "00") & ":"
                    iInspectionID = uRecSnap("InspectionID").Value
                    iInspectionIDcnt = iInspectionIDcnt + 1
                End If
            End If

            aNode = tgvInspections.Nodes(iInspectionIDcnt - 1).Nodes.Add("P" & Format(uRecSnap("InspectionID").Value, "0000"), uRecSnap("AddressLine1").Value)
            aNode.Tag = "P:" & Format(uRecSnap("InspectionID").Value, "0000") & Format(uRecSnap("InspectionID").Value, "0000")
            uRecSnap.MoveNext()

        Loop
        uRecSnap.MoveNext()



        Do Until uRecSnap.EOF

        Loop


        ' Close Connection


    Catch ex As Exception
        ' Catch Error
        If Err.Number <> 0 Then
            WriteAuditLogRecord(uStackframe.GetMethod.DeclaringType.FullName, uStackframe.GetMethod.Name.ToString, "Error", Err.Description & vbCrLf & vbCrLf & ex.StackTrace, 0)
            MsgBox("System Error Ref: " & sAuditID & vbCrLf & uStackframe.GetMethod.DeclaringType.FullName & " / " & uStackframe.GetMethod.Name.ToString & vbCrLf & Err.Description & vbCrLf & vbCrLf & ex.StackTrace & Chr(13) & sErrDescription, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Business Management System - Unexepected Error Ref: " & sAuditID)
        End If

    Finally

        If bConnection Then CloseConnection()
        uRecSnap = Nothing

    End Try
End Sub
末端区域
    ALTER PROCEDURE [dbo].[Inspections_LoadRecords]
    @SearchValue varchar(30) = NULL

AS

BEGIN
    SET NOCOUNT ON;
SELECT        InspectorName.InspectorName, InspectionHeader.InspectionID, InspectorName.InspectorID, InspectionHeader.InspectionDate, InspectionProperties.PropertyID, PropertyMaster.AddressLine1, 

FROM            InspectorName INNER JOIN
                         InspectionHeader ON InspectorName.InspectorID = InspectionHeader.InspectorID INNER JOIN
                         InspectionProperties ON InspectionHeader.InspectionID = InspectionProperties.InspectionID INNER JOIN
                         PropertyMaster ON InspectionProperties.PropertyID = PropertyMaster.PropertyID


                         Where InspectorName.InspectorID = InspectorName.InspectorID

ORDER BY InspectorName.InspectorName

END
Sub LoadInspectionTree()
    '**Loads Property List
    ' Initialise Error Checking


    ' Dimension Local Variables
    Dim uRecSnap As ADODB.Recordset
    Dim uPar As ADODB.Parameter
    Dim uNode As TreeNode
    Dim aNode As TreeNode
    Dim iInspectorID As Integer = 0
    Dim iInspectorcnt As Integer = 0
    Dim iInspectionID As Integer = 0
    Dim iInspectionIDcnt As Integer = 0

    Dim uStackframe As New Diagnostics.StackFrame
    Try

        ' Check For Open Connection
        If uDBase Is Nothing Then
            OpenConnection()
            bConnection = True
        End If

        ' Run Stored Procedure - Load Property List (Based on Search Value)
        uCommand = New ADODB.Command
        With uCommand
            .ActiveConnection = uDBase
            .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
            .CommandTimeout = 0
            uPar = .CreateParameter("@SearchValue", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
            .Parameters.Append(uPar)
            .Parameters("@SearchValue").Value = txtFilter.Text
            .CommandText = "Inspections_LoadRecords"
            uRecSnap = .Execute
        End With


        ' Suppress TreeView Repaint / Clear TreeView
        tgvInspections.BeginUpdate()
        tgvInspections.Nodes.Clear()
        tgvInspections.ShowNodeToolTips = True

        ' Populate List


        Do Until uRecSnap.EOF

            If iInspectorId <> uRecSnap("InspectorID").Value Then
                uNode = tgvInspections.Nodes.Add("G" & Format(uRecSnap("InspectorID").Value, "0000"), uRecSnap("InspectorName").Value)
                uNode.Tag = "G:" & Format(uRecSnap("InspectorID").Value, "0000") & ":0000"
                iInspectorId = uRecSnap("InspectorID").Value
                iInspectorcnt = iInspectorID + 1
                iInspectionID = 0
                iInspectionIDcnt = 0
            End If

            If (IsDBNull(uRecSnap("InspectionID").Value)) = False Then
                If iInspectionID <> uRecSnap("InspectionID").Value Then
                    aNode = uNode.Nodes.Add("I" & Format(uRecSnap("InspectionID").Value, "00"), uRecSnap("InspectionDate").Value)
                    aNode.Tag = "I:" & Format(uRecSnap("InspectionID").Value, "0000") & ":" & Format(uRecSnap("InspectionID").Value, "00") & "0000"
                    iInspectionID = uRecSnap("InspectionID").Value
                    iInspectionIDcnt = iInspectionIDcnt + 1
                End If
            End If

            aNode = uNode.Nodes(iInspectionIDcnt - 1).Nodes.Add("P" & Format(uRecSnap("PropertyID").Value, "0000"), uRecSnap("AddressLine1").Value)
            aNode.Tag = "P:" & Format(uRecSnap("PropertyID").Value, "0000") & Format(uRecSnap("PropertyID").Value, "0000") & "0000"
            uRecSnap.MoveNext()

        Loop




        Do Until uRecSnap.EOF

        Loop
        uRecSnap.Close()


        ' Close Connection


    Catch ex As Exception
        ' Catch Error
        If Err.Number <> 0 Then
            WriteAuditLogRecord(uStackframe.GetMethod.DeclaringType.FullName, uStackframe.GetMethod.Name.ToString, "Error", Err.Description & vbCrLf & vbCrLf & ex.StackTrace, 0)
            MsgBox("System Error Ref: " & sAuditID & vbCrLf & uStackframe.GetMethod.DeclaringType.FullName & " / " & uStackframe.GetMethod.Name.ToString & vbCrLf & Err.Description & vbCrLf & vbCrLf & ex.StackTrace & Chr(13) & sErrDescription, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Business Management System - Unexepected Error Ref: " & sAuditID)
        End If

    Finally

        If bConnection Then CloseConnection()
        uRecSnap = Nothing

    End Try
End Sub