查询语句如下:
var
str,sj1,sj2:string; 
      sj1:=datetostr(datetimepicker1.date)+' '+timetostr(datetimepicker3.Time);
      sj2:=datetostr(datetimepicker2.date)+' '+timetostr(datetimepicker4.Time);
      str:=str+'select * from zlb_lgz_hxcf where rq between '''+sj1+''' and '''+sj2+'''';
运行出现错误:project lgz.exe raised exception class EOleException with message'从字符串转换为datetime时发生语法错误。'.process stopped.use step or  run to continue.
求助:为什么?
之前这个程序我明明已经调试好了的啊,放了1个月再拿出来怎么就出错误了呢?

解决方案 »

  1.   

    加入4个datetimepicker后,调试下面的代码没有问题。procedure TForm1.Button1Click(Sender: TObject);
    var
    str,sj1,sj2:string;
    begin
          sj1:=datetostr(datetimepicker1.date)+' '+timetostr(datetimepicker3.Time);
          sj2:=datetostr(datetimepicker2.date)+' '+timetostr(datetimepicker4.Time);
          str:=str+'select * from zlb_lgz_hxcf where rq between '''+sj1+''' and '''+sj2+'''';
          memo1.lines.text := str;
    end;
      

  2.   

    若是SQL数据库,这里没有问题.再找找其它句子吧,或F7单步调试一下看到那句出错?
      

  3.   

    恩,是时间格式不行,都要换成长日期格式和长时间格式就好了。啊,这一个问题难了我两天!!
    控制面板---区域和语言选项,都改为yyyy-MM-dd和HH:mm:ss就行了。