sqlstr = "select * from 病历收费表 where 日期 between " & DTPicker1.value & "  and " & DTPicker2.Value & " "执行后没有查到任何记录,其实在实际表中是有符合这个时间段的记录的。大家说这是什么问题呢?谢谢!

解决方案 »

  1.   

    sqlstr = "select * from 病历收费表 where 日期 between #" & DTPicker1.value & "#  and #" & DTPicker2.Value & "#"
      

  2.   

    ADO的SQL在时间查询时,时间的两边要加上 # 符号。如 #2004-5-1#。
      

  3.   

    strsql = "select * from test where sj between # " & DTPicker1.value & " # and  # " & DTPicker1.value & " #"试一下
      

  4.   

    " & DTPicker1.value & "和" & DTPicker2.Value & " 是字符串,在VB中用函数他们转换成时间,可以进行比较了
      

  5.   

    如果是sql server,就不要用#号,用'即可:
    strsql = "select * from test where sj between '" & DTPicker1.value & "' and  '" & DTPicker1.value & "'"#用在access数据库中。