troubleshooting Question

For Statemnts not executed

Avatar of Sreekanth_Nagabandi
Sreekanth_Nagabandi asked on
1 Comment1 Solution297 ViewsLast Modified:

  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()

        Dim AlarmConn As SqlConnection

        Dim sql As String

        Dim root As New TreeNode

        root.Text = "Alarm ID " & AlarmId

        root.Value = "ALM" & AlarmId


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

        'Dim Connection As SqlConnection = New SqlConnection(connectionString)
        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 "

            ' 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")

            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)



        Catch ex As Exception
            If AlarmConn.State = ConnectionState.Open Then
            End If
        End Try

    End Sub




Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros