各位大虾看看哪错了:
ADOQuery2.SQL.Text:='select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime)+''' and caozuoyuan='''+Edit7.Text+'''';riqi是日期型的字段,其它的都是字符型的~~~

解决方案 »

  1.   

    ADOQuery2.SQL.Text:='select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+strtodate(FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime))+''' and caozuoyuan='''+Edit7.Text+'''';
      

  2.   

    楼上这位兄弟说的不对哟
    编译后出错:[Error] Unit12.pas(124): Incompatible types: 'String' and 'TDateTime'
      

  3.   

    DateSeparator := '-';
    ShortDateFormat := 'yyyy-mm-dd';
    ADOQuery2.SQL.Text:='select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime)+''' and caozuoyuan='''+Edit7.Text+'''';
    你再试试看
      

  4.   

    我想问一下你主要的意图是什么呢,如果只想把数据库中的记录取出来,那以下方法肯定可以的。
    ADOQuery2.SQL.Text:='select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+datetostr(DateTimePicker1.DateTime)+''' and caozuoyuan='''+Edit7.Text+'''';
      

  5.   

    我想问一下你主要的意图是什么呢,如果只想把数据库中的记录取出来,那以下方法肯定可以的。
    ADOQuery2.SQL.Text:='select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+datetostr(DateTimePicker1.DateTime)+''' and caozuoyuan='''+Edit7.Text+'''';这样编译时出错呀我在上面已经提到了~
      

  6.   

    编译怎么会出错啊,我把中间'select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+datetostr(DateTimePicker1.DateTime)+''' and caozuoyuan='''+Edit7.Text+''''提出当成字符串来编译怎么不出错
      

  7.   

    可编译的时候的确出错:[Error] Unit12.pas(124): Incompatible types: 'TDateTime' and 'String'
      

  8.   

    ADOQuery2.SQL.Text:='select * from cangku where bianhao='''+edit1.Text+''' and DateValue(riqi)=#FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime)# and caozuoyuan='''+Edit7.Text+'''';
    试试
      

  9.   

    你用这段试一个,应该没有问题的
    我试过了,没有出错的
    'select * from cangku where bianhao='''+edit1.Text+''' and riqi='''+DateToStr(DateTimePicker1.DateTime)+''' and caozuoyuan='''+Edit7.Text+''''
      

  10.   

    riqi='''+DateToStr(DateTimePicker1.DateTime)+'''
      

  11.   

    呵呵
    问题解决了
    Shiyl(㊣★¤★㊣) 兄弟的方法是对的,不过你写的这条有些地方引号没打。
    感谢这么多兄弟帮忙了
    好了,我该结帐了。