存计过程如下:------------------------------------------------------------------------
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] ,如果结果较大,可以放在网站上给我一上地址即可。谢谢,如果不明白可以给我留言或是写信。----------------注意:---------------------------------
如果分不够,可以说明,我会用别的贴子给补上的。
-----------------------------------谢谢----------------------------------

解决方案 »

  1.   

    在存储过程的最后既GO的前面做SELECT 语句,把你要查询的东西查出来,然后用ADOStoredProc调它的数据出来就可以了
      

  2.   

    在form上放ADOConnection1、ADOStoredProc1、DataSource1、DBGrid1,分别设置其对应关系,
    在ADOStoredProc1的(TParameters)中设置参数,在查询中对参数付值。
    如果有返回值在DBGrid1里就一定能够显示出来。
      

  3.   

    mrzho(mrzhou) 你说的那个好像不行呀,能不能明白一点呀,兄弟。
      

  4.   

    1 你的存储过程没有返回数据集阿!
    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;
      

  5.   

    ---------------------------------------------------------------------------------
    ---------现在又有新的问题出现了--------------------------------------------------
    我在使用存储过程的时候,使用了下面的语句:
    where field1= case 
    when @a1='' then field1
    else @a1 end
    后,在DELPHI中使用存储过程这个数据源来打开数据库时,就会有提示List index out of bounds(1).不知道这里有没有人知道这是怎么回事,关且在括号中的数字可能是如果正确返回时的记录条数!
    请帮忙!
      

  6.   

    没有写什么代码,只是在按扭的动作中加入了几个StoredProc的参数附值语句,和StoredProc的ACTIVE的开关语句
      

  7.   

    哇,好有历史的帖子啊:)
    你的
    where field1= case 
    when @a1='' then field1
    else @a1 end
    是放在哪里的啊?
    delphi(delphi中是不能这样用的)?sql的存储过程?存储过程的哪里啊?
      

  8.   


    应该是没有数据集返回,不能用Open,只能用execProc;
    Outof..,
    是越界访问造成的如果存储过程由OutPut参数,在存储过程异常结束时没有被赋值,也会出现怪问题
      

  9.   

    打开存储过程要返回数据集时用OPEN