使用DELPHI7的通过ADO JET4.0连接ACCESS97,在使用如下SQL时,DELPHI报错:
"标准表达式中数据类型不匹配"...
源语句:delete from location where Arkname="G00" and row=00 and col=00 and cDate= "2005-1-24 8:42:42" and ENAcode="80150677562"即使将日期时间两边的"改为#同样不行。

解决方案 »

  1.   

    SQL.text:='delete from location where Arkname='+QuotedStr('G00')+' and row=00 .....';
      

  2.   

    请问你用的是双引号还是两个单引号??
    应该用单引号的。(如是SQL属性中,确切说应是两个单引号)
      

  3.   

    不会是单引号问题的。我用的是ACCESS97数据库。
    诸如select * from  where arkname="G00"就执行成功。
      

  4.   

    检查字段Arkname、row、col、cDate和ENAcode的数据类型。
    你把这些字段类型写出来一下。
      

  5.   

    cDate是ACCESS数据库的保留字,换一个名称吧
      

  6.   

    各位大哥啊!
    将这句去掉,没有任何问题!!!
    and cDate= "2005-1-24 8:42:42"
    我将“变成#仍旧报错!!
    同样的语句在ACCESS97的QUERY中却执行正常啊!!!!!!!
      

  7.   

    chwdong(chwdong)说得对:
        mydatetime:='2005-1-24 8:42:42';
        SQL.text:='delete from location where Arkname='
                  + QuotedStr('G00')+' and row=00 and cDate='
                  + mydatetime+' and ENAcode= '
                  + quotedstr(80150677562);
      

  8.   

    delete from location where (Arkname='G00') and (row=00) and (col=00) and (cDate=#2005-1-24 8:42:42#) and (ENAcode='80150677562')
      

  9.   

    还是报错:
    TO: xuxiaozhao_3411(小小) 
    "标准表达式中数据类型不匹配"
    TO:gxgyj(杰克.逊) 
    "对象被不正确的定义。提供了不一致或不完整的信息"........
      

  10.   

    楼主请把你用下面这段代码的代码贴出来:delete from location where (Arkname='G00') and (row=00) and (col=00) and (cDate=#2005-1-24 8:42:42#) and (ENAcode='80150677562')
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄~~~
      

  11.   

    好的。procedure TMain.CancelOpration1Click(Sender: TObject);
    var tmp,n,r,c,tim,encode,typ:string;
    begin
    //UNDO的处理
      tmp:=lv.Selected.Caption;//TMP值为:"G00R00C00"
      n:=copy(tmp,1,3);//柜号
      r:=copy(tmp,5,2);//层(行)号
      c:=copy(tmp,8,2);//格(列)号
      tim:=lv.Selected.SubItems[2];//是"2005-1-24 8:42:42"
      typ:=lv.Selected.SubItems[3];//是"IN"
      encode:=lv.Selected.SubItems[0];//是"80150677562"//条件齐了!可以UNDO了,也就是从LOCATION删除相应记录
      DM.adocmd.CommandText:='delete from location where ([Action]="'+typ+'") and (Arkname="'+n+'") and (row='+r + ') and (col='+c + ') and (cDate= "'+tim + '") and (ENAcode="'+encode +'")';
      DM.adocmd.Execute;
      lv.Selected.Delete;end;
    其中,lv是指listView组件;DM.adocmd是指ADOCommand组件
      

  12.   

    DM.adocmd.CommandText:='delete from location where ([Action]="'+typ+'") and (Arkname="'+n+'") and (row='+r + ') and (col='+c + ') and (cDate= "'+tim + '") and (ENAcode="'+encode +'")';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    delete from location where (Arkname='G00') and (row=00) and (col=00) and (cDate=#2005-1-24 8:42:42#) and (ENAcode='80150677562')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    str:='delete from location where ([Action]='''+typ+''') and (Arkname='''+n+''') and (row='+r + ') and (col='+c + ') and (cDate= #'+tim + '#) and (ENAcode='''+encode +''')';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

  13.   


    TO:gxgyj(杰克.逊) 
    "对象被不正确的定义。提供了不一致或不完整的信息"........
    哎~~~~~~~
    烦呐。。
      

  14.   

    Sql.Text := 'delete from location where Arkname='+QuotedStr("G00") + 'and row=00 and col=00 and cDate='+QuotedStr( "2005-1-24 8:42:42")+' and ENAcode="80150677562"
      

  15.   

    SQL.ADD('delete * from location where Arkname='''+'G00'+'''');
    SQL.ADD('and row=00 and col=00 and cDate= '''+'2005-1-24 8:42:42'+'''');
    SQL.ADD('and ENAcode='''+80150677562'+'''');
      

  16.   

    大哥啊!
    不行啊!!我将其它参数去掉,简化成
    delete from location where  cDate='+QuotedStr( "2005-1-24 8:42:42")
    还是
    delete from location where  cDate="2005-1-24 8:42:42"
    或是
    delete from location where  cDate=#2005-1-24 8:42:42#
    在ACCESS里一切正常,DELPHI里始终是这两个错误信息:
    "标准表达式中数据类型不匹配"

    "对象被不正确的定义。提供了不一致或不完整的信息"........我晕了啊。。
      

  17.   

    delete from location where  cDate=#2005-1-24#//OK
    delete from location where  cDate=#2005-1-24 8:42:42#//不OK
    用参数
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('delete from location where  cDate=:temp');
    adoquery1.Parameters.ParamByName('temp').Value:=edit1.Text;//假设edit1中为:2005-1-24 8:42:42//
    adoquery1.execsql;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    已测试OK....