连接Access数据库,执行一条Sql语句查询表, 莫名其妙的问题!急
Public Sub ICMessage()Dim sSql As String
Dim TagID, DevID As String
Dim SignDT As DateTime
Dim rs As New ADODB.Recordset
Dim now = DateTime.Now.AddSeconds(-10)
Try
Do While True
'and cstr(f_ReadDate) > '" + now + "'
sSql = "select * from t_d_CardRecord where State is null "
If oDB.GetRecordsetForRead(sSql, rs) = True Then
If rs.RecordCount > 0 Then
rs.MoveFirst()
Do While Not rs.EOF
TagID = rs("f_CardNO").Value.ToString()
DevID = rs("f_ControllerSN").Value.ToString()
SignDT = rs("f_ReadDate").Value
'GetInfo_1(TagID, DevID, SignDT)
MsgBox("112233", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "错误")
'oDB.AdoExec("Delete from t_d_CardRecord")
oDB.AdoExec("Update t_d_CardRecord Set State = 0 where f_CardNO ='" & TagID & "'")
rs.MoveNext()
Loop
End If
If rs.State = 1 Then rs.Close()
End If
Loop
Catch ex As Exception
'MsgBox("SUB StartMeetingSign---" & ex.Message)
ErrMsg(ex.Message)
End Try
End Sub
在窗体加载就会执行ICMessage()方法, 然后里面是一个Do While循环, 里面就是一直在实时查找表中t_d_CardRecord数据中字段State = Null的数据! 如果存在,则获取里面的数据,并改变State = 0, 这样就代表该数据过滤掉, 但是问题出现了, State = 0之后, 该数据还能查到一次, 通俗的讲会执行二次 MsgBox("112233", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "错误")! 大家帮我看看问题出现在哪里了! --------------------编程问答-------------------- 你单步调试一下,看在哪句出现错误? --------------------编程问答-------------------- 调试了一步一步走下来, 就是执行一次! 如果不调试, 就是2次! --------------------编程问答-------------------- 有可能取到空值出错
补充:.NET技术 , VB.NET