这是我编的一个每秒种从数据库中取出一条记录的代码,Timer1的Interval=1000
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim strM As String
Dim blnks As Boolean
Private Sub Form_Activate()
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open basLogin.GetFurnaceDBPath, "admin", ""
Set cmd.ActiveConnection = conn
cmd.CommandText = "SELECT * FROM Slag_CAL order by DateTime "
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockOptimistic
If rs.RecordCount > 0 Then
blnks = True
rs.MoveFirst
Timer1_Timer
End If
End Sub
Private Sub Timer1_Timer()
If blnks = True Then
If rs.EOF = True Then
blnks = False
rs.Close
Exit Sub
Else
For i = 0 To 3
With MSHFlexGrid1
.TextMatrix(1, i) = rs.Fields(i)
End With
Next i
rs.MoveNext
End If
End If
End Sub
可运行的时候不对啊,不能完成我想要的结果。请高手帮助,谢谢