Private Sub Command1_Click()
Dim d1 As String
Dim d2 As String
Dim t1 As String
Dim t2 As String
Dim b As Object
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
cn.Open ("Provider=Microsoft.ACE.OLEDB.12.0;data source =" & App.Path & "\bb.accdb;Persist Security Info=False")
d1 = DateValue(rili1(0).Value) + TimeValue(shijian1(1).Value)
t1 = CStr(Format(d1, "yyyy-mm-dd hh:mm:ss"))
d2 = DateValue(rili2(2).Value) + TimeValue(shijian2(3).Value)
t2 = CStr(Format(d2, "yyyy-mm-dd hh:mm:ss"))
'Set b = MSFlexGrid1.object
str = "select * from [minute] where 时间 >= #" & t1 & "# And 时间 <= #" & t2 & "# order by 时间"
MsgBox str
rs.Open str, cn, adOpenStatic, adLockReadOnly
MSFlexGrid1.DataSource = rs
If rs.RecordCount = 0 Then
MsgBox "未查询到数据"
End If
End Sub
显示实时错误13,数据类型不匹配
Dim d1 As String
Dim d2 As String
Dim t1 As String
Dim t2 As String
Dim b As Object
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
cn.Open ("Provider=Microsoft.ACE.OLEDB.12.0;data source =" & App.Path & "\bb.accdb;Persist Security Info=False")
d1 = DateValue(rili1(0).Value) + TimeValue(shijian1(1).Value)
t1 = CStr(Format(d1, "yyyy-mm-dd hh:mm:ss"))
d2 = DateValue(rili2(2).Value) + TimeValue(shijian2(3).Value)
t2 = CStr(Format(d2, "yyyy-mm-dd hh:mm:ss"))
'Set b = MSFlexGrid1.object
str = "select * from [minute] where 时间 >= #" & t1 & "# And 时间 <= #" & t2 & "# order by 时间"
MsgBox str
rs.Open str, cn, adOpenStatic, adLockReadOnly
MSFlexGrid1.DataSource = rs
If rs.RecordCount = 0 Then
MsgBox "未查询到数据"
End If
End Sub
显示实时错误13,数据类型不匹配