string intime1 = this.intime1.Text.Trim();
  string intime2 = this.intime2.Text.Trim();
 sql = "select * from info where  title like'%" + title + "% and intime between '" + intime1 + "' and '" + intime2 + "' order by id desc";
错误提示“标准表达式中数据类型不匹配”不知是什么原因?我用的是ACCESS,intime字段设置为日期格式。请教高手,谢谢!!

解决方案 »

  1.   

    ACCESS的日期用# 
    sql = "select * from info where title like'%" + title + "% and intime between #" + intime1 + "# and #" + intime2 + "# order by id desc";
      

  2.   

    access中的时间查询两端要加#的,还有你的like跟后面的要有空格。string intime1 = this.intime1.Text.Trim();
    string intime2 = this.intime2.Text.Trim();
     sql = "select * from info where title like '%" + title + "%' and intime between #'" + intime1 + "'# and #'" + intime2 + "'# order by id desc";
      

  3.   

    谢谢!!上面两种方法我都试过,都提示:
    日期的语法错误 在查询表达式  title like'%%and intime between #''# and #''#' 中。 
      

  4.   

    select * from info where title like '%aa%' and intime between #2010-12-20 12:23:30# and #2011-10-26 22:48:34# order by id desc;这样的也会报错??
      

  5.   

    你通过debug 加个断点在sql 那个代码上!
    sql 把它拿出来,看看,到Access里试试!不是知道,那错了吗啊?
      

  6.   


    上面的那个表达式是调试得到的sql语句吗?如果是,肯定错了 在access中不是用+,而是@
    sql = "select * from info where title like'%" @ title @ "%' and intime between '" @ intime1 @ "' and '" @ intime2 @ "' order by id desc";
    用这个试试看
      

  7.   

    你的第一个and前面貌似少了一个单引号
      

  8.   

    这样写没错,但我转换成between #intime1# and #intime2#报错
      

  9.   

    string intime1 = this.intime1.Text.Trim();
      string intime2 = this.intime2.Text.Trim();
    ===============
    是这个地方出错了吧,
    检查一下读出的intime1和intime2是多少?