Link to home
Start Free TrialLog in
Avatar of Sreekanth_Nagabandi
Sreekanth_Nagabandi

asked on

For Statemnts not executed

Hi,

  I have replaced the data reader with the dataset and  I have noticed while debugging that this set of statements are not executed. So i will post the  method  with the data set .


Query to be resolved :-

  While working on the Method with the dataset , these following statements are not executed .

  For Each node As TreeNode In root.ChildNodes


                Dim sel_id As Integer = node.Value.Substring(3, node.Value.Length - 3)
                FillCheckNode(sel_id, node)


 
 

 Private Sub DisplayAlarmDetails()

        AlarmView.Nodes.Clear()
        Dim AlarmConn As SqlConnection

        Dim sql As String

        Dim root As New TreeNode

        root.Text = "Alarm ID " & AlarmId

        root.Value = "ALM" & AlarmId

        AlarmView.Nodes.Add(root)

        ' Create a SqlConnection to the Northwind database.
        AlarmConn = New SqlConnection(ConfigurationManager.ConnectionStrings("CMSConnStr").ConnectionString)

        'Dim Connection As SqlConnection = New SqlConnection(connectionString)
        AlarmConn.Open()
        sql = "declare @alarm_id int "
        sql = sql & " set @alarm_id = " & AlarmId & ""
        sql = sql & " Select version_id  from alarm_definition_version "
        sql = sql & " Where version_nbr in "
        sql = sql & " (select max(version_nbr) from alarm_definition_version where alarm_id = @alarm_id) "
        sql = sql & "  and alarm_id = @alarm_id "
        Try

            ' Create a SqlDataAdapter for the alarm_definition_version table.
            Dim AlarmAdapter As SqlDataAdapter = _
               New SqlDataAdapter()

            ' A table mapping names the DataTable.
            AlarmAdapter.TableMappings.Add("Table", "alarm_definition_version")


            ' Create a SqlCommand to retrieve Version data.

            Dim AlarmCommand As SqlCommand = New SqlCommand(sql, AlarmConn)

            AlarmCommand.CommandType = CommandType.Text

            ' Set the SqlDataAdapter's SelectCommand.
            AlarmAdapter.SelectCommand = AlarmCommand
           

            ' Fill the DataSet.
            Dim AlarmSet As DataSet = New DataSet("alarm_definition_version")
            AlarmAdapter.Fill(AlarmSet)

            Dim prev_node As TreeNode = Nothing

            Dim n As New TreeNode
            n = New TreeNode

            'n.Text = " Field Check " & chk_id


            'n.Value = "CHK" & chk_id

            If Not (prev_node Is Nothing) Then

                prev_node.Text = prev_node.Text & " AND"

            End If

            prev_node = n


            For Each node As TreeNode In root.ChildNodes


                Dim sel_id As Integer = node.Value.Substring(3, node.Value.Length - 3)
                FillCheckNode(sel_id, node)


            Next
            AlarmView.ExpandAll()

            root.Select()

        Catch ex As Exception
        Finally
            If AlarmConn.State = ConnectionState.Open Then
                AlarmConn.Close()
            End If
        End Try


    End Sub


 

Thanks,

sreekanth
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial