I use a textBox as an application log display.
I basically iterate through a SQL table in the code below. It gets to the
13th entry on the MISRE_dss_Log table and jumps out excluding all the
subsequent logs(there are 38 all together) in the textBox. Any ideas?
Private Function getLog()
Dim LogtoSet As New ArrayList
For Each Item As Object In ChkListBoxRouti nes.Items
LogtoSet.Add(It em)
Next
For Each Item As Object In LogtoSet
Dim strSQL As String = "SELECT TOP 1 id, log_desc FROM MISRE_dss_log
WHERE LogStat = 'Y' "
Dim cmdSelect As New SqlClient.SqlCo mmand
cmdSelect.Comma ndText = strSQL
cmdSelect.Comma ndType = CommandType.Tex t
Try
cn = New SqlClient.SqlCo nnection("user id=" & UserName.Text &
";password= " & Password.Text & ";database= " & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect.Conne ction = cn
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try
dtr = cmdSelect.Execu teReader(Comman dBehavior.Singl eRow)
If (dtr.Read()) Then
If Not dtr.IsDBNull(0) Then
logid = dtr.GetInt32(0)
logdesc = dtr.GetString(1 )
frmMIS.LogBox.T ext &= logdesc + ControlChars.Cr Lf + ""
MessageBox.Show (logid)
' -- stops at id 13 on the MISRE_dss_log table
Dim strSQL1 As String = "UPDATE MISRE_dss_log SET logStat = 'N' WHERE
id = '" + logid + "' "
Dim cmdSelect1 As New SqlClient.SqlCo mmand
cmdSelect1.Comm andText = strSQL1
cmdSelect1.Comm andType = CommandType.Tex t
Try
cn = New SqlClient.SqlCo nnection("user id=" & UserName.Text &
";password= " & Password.Text & ";database= " & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect1.Conn ection = cn
cmdSelect1.Exec uteNonQuery()
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try
End If
End If
dtr.Close()
cn.Close()
cn.Dispose()
Next
End Function
I basically iterate through a SQL table in the code below. It gets to the
13th entry on the MISRE_dss_Log table and jumps out excluding all the
subsequent logs(there are 38 all together) in the textBox. Any ideas?
Private Function getLog()
Dim LogtoSet As New ArrayList
For Each Item As Object In ChkListBoxRouti nes.Items
LogtoSet.Add(It em)
Next
For Each Item As Object In LogtoSet
Dim strSQL As String = "SELECT TOP 1 id, log_desc FROM MISRE_dss_log
WHERE LogStat = 'Y' "
Dim cmdSelect As New SqlClient.SqlCo mmand
cmdSelect.Comma ndText = strSQL
cmdSelect.Comma ndType = CommandType.Tex t
Try
cn = New SqlClient.SqlCo nnection("user id=" & UserName.Text &
";password= " & Password.Text & ";database= " & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect.Conne ction = cn
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try
dtr = cmdSelect.Execu teReader(Comman dBehavior.Singl eRow)
If (dtr.Read()) Then
If Not dtr.IsDBNull(0) Then
logid = dtr.GetInt32(0)
logdesc = dtr.GetString(1 )
frmMIS.LogBox.T ext &= logdesc + ControlChars.Cr Lf + ""
MessageBox.Show (logid)
' -- stops at id 13 on the MISRE_dss_log table
Dim strSQL1 As String = "UPDATE MISRE_dss_log SET logStat = 'N' WHERE
id = '" + logid + "' "
Dim cmdSelect1 As New SqlClient.SqlCo mmand
cmdSelect1.Comm andText = strSQL1
cmdSelect1.Comm andType = CommandType.Tex t
Try
cn = New SqlClient.SqlCo nnection("user id=" & UserName.Text &
";password= " & Password.Text & ";database= " & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect1.Conn ection = cn
cmdSelect1.Exec uteNonQuery()
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try
End If
End If
dtr.Close()
cn.Close()
cn.Dispose()
Next
End Function
Comment