select a.cpcode,a.barcode,a.pm,a.dw,a.guige,a.beizhu,a.minsl,a.jhj,a.pfj,a.lsj,a.ghscode,Vendor.name
,Vendor.address,totxsb.xssl as xssltot,sum(Onhand.kcsl) as kcsltot
,(convert (int,onhand.kcsl) / convert (int,(a.lunit))) as jianshu
, (convert (int,onhand.kcsl) % convert (INT,(a.LUNIT))) as sanshu
 from goods a left outer join Onhand on a.cpcode=Onhand.cpcode
 left outer join Vendor on a.ghscode=Vendor.ghscode
 left outer join totxsb on a.cpcode=totxsb.cpcode where (a.status=0)
 group by a.cpcode,a.barcode,a.pm,a.dw,a.guige,a.beizhu,a.minsl,a.jhj,a.pfj,a.lsj,a.ghscode,
Vendor.name,Vendor.address,totxsb.xssl
,(convert (int,onhand.kcsl) / convert (int,(a.lunit))) as jianshu 
, (convert (int,onhand.kcsl) % convert (int,(a.lunit))) as sanshu
这段代码有什么问题啊?
我在SQL查询分析器里可以查得出数据,可是在DELPHI里我在query里
想Add Fields时,却报错
说: 
Invalid use of keyword.
Token: int,onhand.kcsl)
Line Nunber:4
可是这代码我在SQL查询分析器里可以查得出数据啊!

解决方案 »

  1.   

    你的SQL语句在Delphi里面是怎么写的? 贴出来看看
      

  2.   

     我也碰到過這種情況的,代碼在SQL裏能執行,但在D裏執行報錯。後來我看過,是因為特殊字符的問題 
      

  3.   

    SQL语句我在SQL SERVER中测试时正确的
    不知道你用的是什么数据库?? 
      

  4.   

    在SQL SERVER数据库中测试正确,但是不能保证你在DELPHI中的SQL语句就正确,好好看看你在DELPHI中的SQL语句吧