我想把查询到的符合两个时间内的数据显示在DataGrid1上,可我的程序DataGrid1上只显示一条空数据。这是怎么回事啊
Dim strSQL As String
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\abc\1.mdb;Persist Security Info=False"
strSQL = "select*from 123 where 时间 between #" & DTP1.Value & "# and #" & DTP2.Value & "#"
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open strSQL, conn, adOpenStatic, adLockReadOnly
Set DataGrid1.DataSource = rs

解决方案 »

  1.   

    '确认时间段范围内是否有记录
    strSQL = "select * from 123 where 时间 between #" & DTP1.Value & "# and #" & DTP2.Value & "#"
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open strSQL, conn, adOpenkeyset, adLockReadOnly
    Set DataGrid1.DataSource = rs
      

  2.   

    在代码中加入:msgbox strSQL,执行到这句时看看具体的SQL语句
      

  3.   

    select * from 123 where 时间 between #2010-04-27 00:59:59 "# and #2010-04-27 10:00:00#"msgbox显示这句
      

  4.   

    没有"
    select * from 123 where 时间 between #2010-04-27 00:59:59 # and #2010-04-27 10:00:00#
      

  5.   

    到数据表中执行这句看看:
    select * from 123 where 时间 between #2010-04-27 00:59:59 # and #2010-04-27 10:00:00#
      

  6.   

    '要用英文输入法状态下的冒号
    select * from 123 where 时间 between #2010-04-27 00:59:59 # and #2010-04-27 10:00:00#
      

  7.   

    格式是对了,可查出来的还是空数据,好像查询的条件不对。
    我变了个条件strSQL = "select * from 123 where 压力 =24"查询就很好用查询2个时间之间的数据还有别的查询条件吗