存计过程如下:------------------------------------------------------------------------
CREATE proc dbo.SALESSLIP @BEGDATE DATETIME,--'销售出库单起始日期
@ENDDATE DATETIME, --'销售出库单结束日期
@BILLNOS VARCHAR(15) ,--'销售代码起始区间
@BILLNOE VARCHAR(15) ,--'销售代码结束区间
@CLIENTN VARCHAR(80) ,
@SWDJH VARCHAR(20)
--@CLNO1 VARCHAR(80) = '0',--'客户代码起始区间
--@CLNO2 VARCHAR(80) = 'ZZZZZZZZZZZZZZZ'--'客户代码终止区间 as
update t_icitem
set f_102=''
where f_102 is null
select
t4.fdate as kprq ,
t4.fbillno as fpdm,
t1.fname as khmc,
t1.ftaxnum as khswdjh,
t1.faddress as khdz,
t1.fbank+' '+t1.faccount as khyh,
t2.fname as cpmc,
t2.fmodel as xh,
case t2.f_102
when '' then t2.fmodel
else t2.f_102
end as cpth ,
t2.fnumber as cpdm,
t3.fname as cpdw,
t2.fplanprice as xxdj,
t5.fqty as cpsl,
t2.f_106 as cplb,
'' as selected
from t_organization t1,t_icitem t2,t_item t3,icstockbill t4,icstockbillentry t5
where t4.ftrantype=21 and t4.fcancellation=0 and t4.fstatus=1 and t4.f_drbj is null
and t1.fitemid=t4.fsupplyid
and t2.fitemid=t5.fitemid
and t2.funitid=t3.fitemid
and t4.finterid=t5.finterid
--开票日期
and t4.fdate >=isnull(@BEGDATE,t4.fdate) and t4.fdate <= isnull(@ENDDATE,t4.fdate)
--销售单号
-- and t4.fbillno >=isnull( @BILLNOS,t4.fbillno) and t4.fbillno <= isnull(@BILLNOE,t4.fbillno)
and t4.fbillno >= case
when @BILLNOS ='' THEN t4.fbillno
when @BILLNOS is null THEN t4.fbillno
when @BILLNOS = 'all' THEN '0' else @BILLNOS end
and t4.fbillno <= case
when @BILLNOE ='' THEN t4.fbillno
when @BILLNOE is null THEN t4.fbillno
when @BILLNOE = 'all' THEN 'ZZZZZZZZZZ'
else @BILLNOE end
--客户税纳税号
and t1.ftaxnum = case when
@SWDJH ='' then t1.ftaxnum
when @SWDJH is null then t1.ftaxnum
when @SWDJH='all' then t1.ftaxnum
else @SWDJH end
--客户名称
and t1.fname= case when
@CLIENTN ='' then t1.fname
when @CLIENTN is null then t1.fname
when @CLIENTN = 'all' then t1.fname
else @CLIENTN end
order by
t4.fdate,t4.fbillno
GO----------------以上所示为存储过程----------------------
--------------------------------------------------------
现要求在 DELPHI/C++ BUILDER 中使用ADO页的存储过程来打开上面的存储过程,并且用DataSource -> DBGrid来显示由存储过程所得到的数据。当然过程的入口是由在DELPHI 中用 DateTimePicker / Edit 来得到。对上面的过程用的库可以保证无任何问题,如果有兴趣的可以用一个假的数据库来做,或者您也可以在下面留下信箱,我会很快给你发过去的,并且稍后我会贴出部分数据来。如果有结果也可以发到我的信箱:[email protected] / [email protected] ,如果结果较大,可以放在网站上给我一上地址即可。谢谢,如果不明白可以给我留言或是写信。----------------注意:---------------------------------
如果分不够,可以说明,我会用别的贴子给补上的。
-----------------------------------谢谢----------------------------------
CREATE proc dbo.SALESSLIP @BEGDATE DATETIME,--'销售出库单起始日期
@ENDDATE DATETIME, --'销售出库单结束日期
@BILLNOS VARCHAR(15) ,--'销售代码起始区间
@BILLNOE VARCHAR(15) ,--'销售代码结束区间
@CLIENTN VARCHAR(80) ,
@SWDJH VARCHAR(20)
--@CLNO1 VARCHAR(80) = '0',--'客户代码起始区间
--@CLNO2 VARCHAR(80) = 'ZZZZZZZZZZZZZZZ'--'客户代码终止区间 as
update t_icitem
set f_102=''
where f_102 is null
select
t4.fdate as kprq ,
t4.fbillno as fpdm,
t1.fname as khmc,
t1.ftaxnum as khswdjh,
t1.faddress as khdz,
t1.fbank+' '+t1.faccount as khyh,
t2.fname as cpmc,
t2.fmodel as xh,
case t2.f_102
when '' then t2.fmodel
else t2.f_102
end as cpth ,
t2.fnumber as cpdm,
t3.fname as cpdw,
t2.fplanprice as xxdj,
t5.fqty as cpsl,
t2.f_106 as cplb,
'' as selected
from t_organization t1,t_icitem t2,t_item t3,icstockbill t4,icstockbillentry t5
where t4.ftrantype=21 and t4.fcancellation=0 and t4.fstatus=1 and t4.f_drbj is null
and t1.fitemid=t4.fsupplyid
and t2.fitemid=t5.fitemid
and t2.funitid=t3.fitemid
and t4.finterid=t5.finterid
--开票日期
and t4.fdate >=isnull(@BEGDATE,t4.fdate) and t4.fdate <= isnull(@ENDDATE,t4.fdate)
--销售单号
-- and t4.fbillno >=isnull( @BILLNOS,t4.fbillno) and t4.fbillno <= isnull(@BILLNOE,t4.fbillno)
and t4.fbillno >= case
when @BILLNOS ='' THEN t4.fbillno
when @BILLNOS is null THEN t4.fbillno
when @BILLNOS = 'all' THEN '0' else @BILLNOS end
and t4.fbillno <= case
when @BILLNOE ='' THEN t4.fbillno
when @BILLNOE is null THEN t4.fbillno
when @BILLNOE = 'all' THEN 'ZZZZZZZZZZ'
else @BILLNOE end
--客户税纳税号
and t1.ftaxnum = case when
@SWDJH ='' then t1.ftaxnum
when @SWDJH is null then t1.ftaxnum
when @SWDJH='all' then t1.ftaxnum
else @SWDJH end
--客户名称
and t1.fname= case when
@CLIENTN ='' then t1.fname
when @CLIENTN is null then t1.fname
when @CLIENTN = 'all' then t1.fname
else @CLIENTN end
order by
t4.fdate,t4.fbillno
GO----------------以上所示为存储过程----------------------
--------------------------------------------------------
现要求在 DELPHI/C++ BUILDER 中使用ADO页的存储过程来打开上面的存储过程,并且用DataSource -> DBGrid来显示由存储过程所得到的数据。当然过程的入口是由在DELPHI 中用 DateTimePicker / Edit 来得到。对上面的过程用的库可以保证无任何问题,如果有兴趣的可以用一个假的数据库来做,或者您也可以在下面留下信箱,我会很快给你发过去的,并且稍后我会贴出部分数据来。如果有结果也可以发到我的信箱:[email protected] / [email protected] ,如果结果较大,可以放在网站上给我一上地址即可。谢谢,如果不明白可以给我留言或是写信。----------------注意:---------------------------------
如果分不够,可以说明,我会用别的贴子给补上的。
-----------------------------------谢谢----------------------------------
解决方案 »
- delphi exe 传递参数问题
- 关于数据库统计的速度问题?
- image类型问题
- database中设置ENABLE BCD=TRUE有什么作用呢??
- 公安ccic库是oracle吗?我不会添加进数据库,扩展名是.dat
- 请高手朋友帮忙
- 请各位给解释一下!!很快结贴!!!
- 为什么我的程序一按运行就连整个DELPHI 都关闭掉了?帮我找出问题,马上给200分!高手帮忙呀!
- 想用QuickReport实现一个万能报表,希望各位大虾给点建议
- 能不能在一个DataModule上放两个database?答者有分
- 谁能给份关于摄像头捕捉视频信息的并保存的完整源码?
- 如何剪裁JPG图片的某一部分并保存成到文件?
在ADOStoredProc1的(TParameters)中设置参数,在查询中对参数付值。
如果有返回值在DBGrid1里就一定能够显示出来。
2 参数太多,我给你一个例子,自己看着在把其他的参数加上
try
ADOStoredProc := TADOStoredProc.Create(nil);
ADOStoredProc.Connection := ADOConnection; ADOStoredProc.ProcedureName :='SALESSLIP';
...
ADOStoredProc.Parameters.CreateParameter('BILLNOS', ftString, pdInput, 15, BILLNOS);
ADOStoredProc.Parameters.CreateParameter('BILLNOE', ftString, pdInput, 15, BILLNOE); ADOStoredProc.Prepared := True;
ADOStoredProc.ExecProc;
//..其他处理
finally
ADOStoredProc.Free;
end;
---------现在又有新的问题出现了--------------------------------------------------
我在使用存储过程的时候,使用了下面的语句:
where field1= case
when @a1='' then field1
else @a1 end
后,在DELPHI中使用存储过程这个数据源来打开数据库时,就会有提示List index out of bounds(1).不知道这里有没有人知道这是怎么回事,关且在括号中的数字可能是如果正确返回时的记录条数!
请帮忙!
你的
where field1= case
when @a1='' then field1
else @a1 end
是放在哪里的啊?
delphi(delphi中是不能这样用的)?sql的存储过程?存储过程的哪里啊?
应该是没有数据集返回,不能用Open,只能用execProc;
Outof..,
是越界访问造成的如果存储过程由OutPut参数,在存储过程异常结束时没有被赋值,也会出现怪问题