rs.Open "select Time from NationalFamous where Time '" + CmbRelation.text + "'  '" + DTPvalue.value + "'", cn, adOpenStatic, adLockReadOnlytime 是数据库中时间的字段
NATIONAFAMOUS  是表名
CMBRELATION   是COMBOBOX 里面有= ≠ ≤ ≥ Like
dtpvalue.value    DTPICKER控件   是所要输入的时间我什么地方写错了,
谢谢。出错信息是
error number   13
type mismatch

解决方案 »

  1.   

    rs.Open "select Time from NationalFamous where Time between '" + CmbRelation.text + "' and '" + DTPvalue.value + "'", cn, adOpenStatic, adLockReadOnly
      

  2.   

    单引号位置放错了:
    rs.Open "select Time from NationalFamous where Time" + CmbRelation.text + "'" + DTPvalue.value + "'", cn, adOpenStatic, adLockReadOnly
      

  3.   

    不知你用的是何数据库若为access时间格式为#yyyy-mm-dd#
      

  4.   

    txtsql="select Time from NationalFamous where Time " + CmbRelation.text + "  '" + DTPvalue.value + "'"
    msgbox txtsql 检测结果出错,
    信息是
    error number   13
    type mismatch
      

  5.   

    将 time改为另一个名字试试,可能为关键字
      

  6.   

    Time 是系统保留的关键字,引用的时候要用方括号扩起来。
    rs.Open "select [Time] from NationalFamous where [Time] '" + CmbRelation.text + "'  '" + DTPvalue.value + "'", cn, adOpenStatic, adLockReadOnly
      

  7.   

    rs.Open "select Time from NationalFamous where Time between '" + CmbRelation.text + "' and '" + DTPvalue.value + "'", cn, adOpenStatic, adLockReadOnly
      

  8.   

    先改你的字段名: Time 改为 mTime, 然后执行如下代码:
    Access的:
    rs.Open "select mTime from NationalFamous where mTime  " & CmbRelation.text & "#" &  Format(DTPvalue.value,"yyyy-mm-dd") & "#", cn, adOpenStatic, adLockReadOnly
    SQL的:
    rs.Open "select mTime from NationalFamous where mTime  " & CmbRelation.text & "'" &  Format(DTPvalue.value,"yyyy-mm-dd") & "'", cn, adOpenStatic, adLockReadOnlyCmbRelation.text 必须是运算符.
    另外,在VB中 Date 类型最好不要用 = 做比较,否则你会后悔(小心客户不付项目尾数!).
      

  9.   

    你可以在输入的时候用DTPICKER空件,在存入数据库是你用文本存,查询的时候就会省去很多不必要的麻烦!