vb连接access的问题

来源:百度知道 编辑:UC知道 时间:2024/04/28 08:03:36
Private Sub Command1_Click()
Dim sSQL As String
Dim A As String
Dim B As Date '我改成了日期格式,然后就提示下面的有错误,下面的改怎么改啊?'
Dim C As Date
A = Trim(Text1.Text)
B = Trim(Text2.Text)
C = Trim(Text3.Text)
Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Program Files\VB98\gongcheng\db8.mdb;Persist Security Info=False"
cn.Open
rs.CursorLocation = adUseClient
rs.Open "select * from 爆炸物品出库记录(有编号) where ( 领取人 = '" & A & " ')and (出库时间 between '" & B & " 'and '" & C & "') ", cn, 3, 1
Set DataGrid1.DataSource = rs
Exit Sub
End If
End Sub

rs.Open "select * from 爆炸物品出库记录(有编号) where ( 领取人 = '" & A & " ')and (出库时间 between #" & B & "# and '" & C & "') ", cn, 3, 1

日期两旁用#号 然后 你数据库中的时间字段也要设置成日期型。

提示的错误内容是什么?

建议TextBox2、TextBox3用DTPicker控件