使用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"即使将日期时间两边的"改为#同样不行。
"标准表达式中数据类型不匹配"...
源语句:delete from location where Arkname="G00" and row=00 and col=00 and cDate= "2005-1-24 8:42:42" and ENAcode="80150677562"即使将日期时间两边的"改为#同样不行。
解决方案 »
- 如何删除ini文件中的所有内容?
- 如何清除Image构件上次用Canvas绘制的图形?
- Delphi中如何继行?像C中的'\\'
- 请问:在用pop3下载邮件附件时,会自动下载temp1.mme文件,这个文件起什么作用?
- 请问在DELPHI中的出错机制如何实现?
- 请教高手:一个查询问题?
- 如何在合并word文档的时候.两篇文档之间加入分页符? cg1120(代码最优化)老兄,回得话快来领分丫!
- delphi 如何修改桌面快捷方式
- 多线程技术
- 关于RealPlay文件的播放
- 如何使两个窗口总在最前面
- (完整源码)第一次使用FastReport出现的问题,在FR2.5中正确,但用FR3.07编译通不过.请问是怎么回事
应该用单引号的。(如是SQL属性中,确切说应是两个单引号)
诸如select * from where arkname="G00"就执行成功。
你把这些字段类型写出来一下。
将这句去掉,没有任何问题!!!
and cDate= "2005-1-24 8:42:42"
我将“变成#仍旧报错!!
同样的语句在ACCESS97的QUERY中却执行正常啊!!!!!!!
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);
TO: xuxiaozhao_3411(小小)
"标准表达式中数据类型不匹配"
TO:gxgyj(杰克.逊)
"对象被不正确的定义。提供了不一致或不完整的信息"........
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄~~~
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组件
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 +''')';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TO:gxgyj(杰克.逊)
"对象被不正确的定义。提供了不一致或不完整的信息"........
哎~~~~~~~
烦呐。。
SQL.ADD('and row=00 and col=00 and cDate= '''+'2005-1-24 8:42:42'+'''');
SQL.ADD('and ENAcode='''+80150677562'+'''');
不行啊!!我将其它参数去掉,简化成
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里始终是这两个错误信息:
"标准表达式中数据类型不匹配"
或
"对象被不正确的定义。提供了不一致或不完整的信息"........我晕了啊。。
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....