一個問題讓我痛苦一下午!(25分)

  • 主题发起人 主题发起人 hurryman
  • 开始时间 开始时间
H

hurryman

Unregistered / Unconfirmed
GUEST, unregistred user!
一個問題讓我痛苦一下午!
在我作報表時遇到的問題:
我用ADOdataset与QuickRep連接,
當我的ADOdataset.Commandtext為時:
select pcps.dept, pdate,pcode, pcps.type, cont, pcps.rmb,pcps.hkd,rece,rmk,
sum(rmb1) as a ,sum(rmb2) as b ,sum(rmb3) as c,sum(hkd1) as d ,sum(hkd2) as e ,sum(hkd3) as f
,sum(psal.rmb) as g ,sum(psal.hkd) as h
from pcps ,psal ,dept
where pcps.dept=psal.dept and pcps.pdate between '01/01/2002' and '01/30/2002'
~~~~~~~~~~~~~ ~~~~~~~~~~~~
and pcps.dept between 'db01' and 'db50' and pcps.dept=dept.dept
~~~~~ ~~~~~~~
group by pcps. dept,pdate,pcode,pcps.type,cont,pcps.rmb,pcps.hkd,rece,rmk

右擊QuickRep預覽是對的(測試)
而當我的ADOdataset.Commandtext為時:

select pcps.dept, pdate,pcode,pcps.type,cont,pcps.rmb,pcps.hkd,rece,rmk,
sum(rmb1) as a ,sum(rmb2) as b ,sum(rmb3) as c,sum(hkd1) as d ,sum(hkd2) as e ,sum(hkd3) as f
,sum(psal.rmb) as g ,sum(psal.hkd) as h
from pcps ,psal ,dept
where pcps.dept=psal.dept and pcps.pdate between :fdate and :edate
~~~~~~~ ~~~~~~
and pcps.dept between :fdept and :edept and pcps.dept=dept.dept
~~~~~~~ ~~~~~~
group by pcps. dept,pdate,pcode,pcps.type,cont,pcps.rmb,pcps.hkd,rece,rmk
order by pcps.dept ,pdate
******************************************************
begin
application.CreateForm(tform12,form12);
form12.QRLabel5.Caption :=datetostr(tempdate1);
form12.QRLabel6.Caption :=datetostr(tempdate2);
with form12.ADODataSet1 do
begin
active :=false;
Parameters.ParamByName('fdate').Value :=tempdate1;
parameters.ParamByName('edate').Value :=tempdate2;
parameters.ParamByName('fdept').Value :=tempdept1;
parameters.ParamByName('edept').Value :=tempdept2;
active :=true;
end;
form12.QuickRep1.Preview ;
form12.close;
end;
******************************
報表里沒有數据,這到底升錯在哪里?
 
没试过,一般预览正确就OK了
 
but i don't know the trouble!
help me every body.
 
没遇到过该情况,不过,可以教你个调试方法:
将你的ADODataSet1连到一个dbgrid中,
看是否有数据被查询出来,如果有数据回来,说明
不是SQL语句的问题。
如果没数据回来,就是SQL语句的问题,你可以加一句
prepare预处理一下SQL语句。
如果还不行,我也不知道是什么问题了
 
在预览前看加中断一下commandtext中是否你预期的sql语句
还有加个dbgrid看一下也是不错的建议
 
后退
顶部