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(Configuratio nManager.C onnectionS trings("CM SConnStr") .Connectio nString)
'Dim Connection As SqlConnection = New SqlConnection(connectionSt ring)
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("Tabl e", "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
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(Configuratio
'Dim Connection As SqlConnection = New SqlConnection(connectionSt
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
' 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
' Fill the DataSet.
Dim AlarmSet As DataSet = New DataSet("alarm_definition_
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.