各位高手:
我是初学VB做数据库编程,用的是ACCESS数据库。
现在做自动提示功能。把数据库的记录时间与系统时间对比。
这是我写的代码:
Private Sub Form_Load()
Dim rS As New ADODB.Recordset
Dim sqlstmt As String
sqlstmt = "select * from 预约单 WHERE 预约时间 LIKE " + Trim(Str(Label1.Caption))
Set rS = sqltmt
If rS.EOF Then
MsgBox "有预约", "请注意"
End If
End Sub
Sub timer1_timer()
Label1.Caption = Time$()
End Sub
我用的是TIMER控件控制 作者:
Nothing 时间: 2006-7-20 17:50
你的代码不应当加到Load里面,应当加对Timer1_timer中,当到时的自动提醒
Dim rS As New ADODB.Recordset
Dim sqlstmt As String
sqlstmt = "select * from 预约单 WHERE 预约时间>='" & now& "'"
Set rS = sqltmt
If rS.EOF Then
MsgBox "有预约", "请注意"
End If 作者:
qxl584 时间: 2006-7-29 10:43
看不懂你Time$()是干嘛的。
应该这样写
Sub timer1_timer()
Dim objConn As New ADODB.Connection
Dim strConn As String
strConn = "rovider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdbersist Security Info=False"
objConn.Open strConn
Dim rS As New ADODB.Recordset
Dim sqlstmt As String
sqlstmt = "select * from 预约单 WHERE 预约时间 LIKE " + Trim(Str(Label1.Caption))
Set rS = objConn.execute(sqlstmt)
If rS.EOF Then
MsgBox "有预约", "请注意"
End If
rs.close
set rs=nothing
objConn.close
set objConn=nothing
End Sub