报错“标准表达式数据类型不匹配”"出租日期的字段类型为日期型"
改为文本的就可以通过,但是计算日期时有错
怎么改?
Private Sub Command1_Click()
Dim CN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Rs2 As New ADODB.Recordset
Dim SQL As String
Const DBPATH = "d:\czyy\yyzl.MDB"
Const ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPATH
Dim 编号, 片名, 租金, 押金 As String
CN.Open ConnString SQL = "SELECT sum(合计押金) as yj ,sum(合计租金)as zj FROM zl_hz "
SQL = SQL & "WHERE 出租日期>='" & DTPicker1.Value & "' and 出租日期<'" & DTPicker2.Value + 1 & "'"
Rs.Open SQL, ConnString, , , adCmdText
If Rs.EOF = False Then Label1.Caption = "合计收取押金" & Rs("yj") & "元"
Label3.Caption = "合计收取租金" & Rs("zj") & "元"
Rs.Close
CN.Close
Else
MsgBox "没有您要查找的记录! ", vbInformation, "信息提示"
Rs.Close
CN.Close
End If
End Sub
改为文本的就可以通过,但是计算日期时有错
怎么改?
Private Sub Command1_Click()
Dim CN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Rs2 As New ADODB.Recordset
Dim SQL As String
Const DBPATH = "d:\czyy\yyzl.MDB"
Const ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPATH
Dim 编号, 片名, 租金, 押金 As String
CN.Open ConnString SQL = "SELECT sum(合计押金) as yj ,sum(合计租金)as zj FROM zl_hz "
SQL = SQL & "WHERE 出租日期>='" & DTPicker1.Value & "' and 出租日期<'" & DTPicker2.Value + 1 & "'"
Rs.Open SQL, ConnString, , , adCmdText
If Rs.EOF = False Then Label1.Caption = "合计收取押金" & Rs("yj") & "元"
Label3.Caption = "合计收取租金" & Rs("zj") & "元"
Rs.Close
CN.Close
Else
MsgBox "没有您要查找的记录! ", vbInformation, "信息提示"
Rs.Close
CN.Close
End If
End Sub
将'号改成#号
ACCESS数据库就是这个样子的。
在看一条
难道这个也要改吗,我改了也不行
能告诉我怎么样才吧‘该为#呢?
Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "请输入正确的工号!", vbInformation, "信息提示"
Else
CN.Open ConnString
SQL = "SELECT * FROM user "
SQL = SQL & "WHERE 工号 ='" & Text1.Text & "' "
Rs.Open SQL, ConnString, , , adCmdText
If Rs.EOF = True Then
MsgBox "请输入正确的工号!", vbInformation, "信息提示"
Else
If Text3.Text = Rs("密码") Then
Form5.Show
Else
MsgBox "您输入的密码不正确!", vbInformation, "信息提示"
End If
End If
End If
End Sub