select * from student 
where 日期 between " + Chr(35) + Str(DTP1.Value) + Chr(35) + "and " + Chr(35) + Str(DTP2.Value) + Chr(35) + "& " & Combo1.text & " order by 编号

解决方案 »

  1.   

    select * from student 
    where 日期 between "" + Chr(35) + Str(DTP1.Value) + Chr(35) and "" + Chr(35) + Str(DTP2.Value) + Chr(35) + "& " & Combo1.text  order by 编号
      

  2.   

    为什么要用chr(35)?直接#了:
    sql="select * from student 
    where 日期 between #"& format(DTP1.Value,"yyyy-mm-dd") & "# and #"format(DTP2.Value,"yyyy-mm-dd") &"# " & Combo1.text & " order by 编号
      

  3.   

    不知道Combo1.text 中是什么,貌似与前面之间要用and连接
      

  4.   

    "select * from student where 日期>= '" + Str(DTPicker1.Value) + "'and  order_date<='" + Str(DTPicker2.Value) + "' "& combo1.text &"order by 编号"现在是combo1.text那出错
    combo1.text是所选的字符条件
      

  5.   

    "select * from student where 日期>= '" + Str(DTPicker1.Value) + "'and  order_date<='" + Str(DTPicker2.Value) + "' and 字段名称='"& combo1.text &"' order by 编号"看你改#为'是SQL数据库?还有为什么要用str,或是文本型字段?
    还有VB的话,最好改+为&
      

  6.   

    where 日期 between '" + Chr(35) + Str(DTP1.Value) + Chr(35) + "' and '" + Chr(35) + Str(DTP2.Value) + Chr(35) + "' & " & Combo1.text & " order by 编号日期加单引号
      

  7.   

    前面部分没出错,关键是 & "& combo1.text & " order by 编号 这句,如果没有这句,前面的可能通过
      

  8.   

    字段名称='"& combo1.text &"' order by 编号
      

  9.   

    字段名称='"& combo1.text &"' order by 编号