G
Guest
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 ChkListBoxRoutines.Items
LogtoSet.Add(Item)
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.SqlCommand
cmdSelect.CommandText = strSQL
cmdSelect.CommandType = CommandType.Text
Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text &
";password=" & Password.Text & ";database=" & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect.Connection = cn
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try
dtr = cmdSelect.ExecuteReader(CommandBehavior.SingleRow)
If (dtr.Read()) Then
If Not dtr.IsDBNull(0) Then
logid = dtr.GetInt32(0)
logdesc = dtr.GetString(1)
frmMIS.LogBox.Text &= logdesc + ControlChars.CrLf + ""
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.SqlCommand
cmdSelect1.CommandText = strSQL1
cmdSelect1.CommandType = CommandType.Text
Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text &
";password=" & Password.Text & ";database=" & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect1.Connection = cn
cmdSelect1.ExecuteNonQuery()
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 ChkListBoxRoutines.Items
LogtoSet.Add(Item)
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.SqlCommand
cmdSelect.CommandText = strSQL
cmdSelect.CommandType = CommandType.Text
Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text &
";password=" & Password.Text & ";database=" & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect.Connection = cn
Catch ex As Exception
sqlCnError = ("Error: Could not establish database connection")
End Try
dtr = cmdSelect.ExecuteReader(CommandBehavior.SingleRow)
If (dtr.Read()) Then
If Not dtr.IsDBNull(0) Then
logid = dtr.GetInt32(0)
logdesc = dtr.GetString(1)
frmMIS.LogBox.Text &= logdesc + ControlChars.CrLf + ""
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.SqlCommand
cmdSelect1.CommandText = strSQL1
cmdSelect1.CommandType = CommandType.Text
Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text &
";password=" & Password.Text & ";database=" & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect1.Connection = cn
cmdSelect1.ExecuteNonQuery()
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