有sql server 2000存储过程如下,在sql查询分析器正常执行并返回@zj
CREATE PROCEDURE xsqbxs
@zj numeric(10,2) output
AS
select x_djrq,x_spbm,x_spmc,x_sl,x_zhdj,x_zhje,x_id from xsdb
begin
select @zj=sum(x_zhje) from xsdb
end
GO在Delphi7窗体中有1个dbgrid和1个label 执行如下代码(如果不用返回值能在dbgrid正常显示数据)procedure Txc_xs.GetAll;
begin
with xc.ADODataSet1 do
begin
Active:=false;
CommandType:=cmdStoredProc;
CommandText:='xsqbxs';
Active:=true;
ExecuteOptions;
end;
end;procedure Txc_xs.xc_xsshow(Sender: TObject);
begin
GetAll;
label1.Caption:=???? //显示返回值
end;问题:
1、执行后出现“过程需要参数@zj”的错误,如何将@zj写入代码
2、如何在label1显示返回值
CREATE PROCEDURE xsqbxs
@zj numeric(10,2) output
AS
select x_djrq,x_spbm,x_spmc,x_sl,x_zhdj,x_zhje,x_id from xsdb
begin
select @zj=sum(x_zhje) from xsdb
end
GO在Delphi7窗体中有1个dbgrid和1个label 执行如下代码(如果不用返回值能在dbgrid正常显示数据)procedure Txc_xs.GetAll;
begin
with xc.ADODataSet1 do
begin
Active:=false;
CommandType:=cmdStoredProc;
CommandText:='xsqbxs';
Active:=true;
ExecuteOptions;
end;
end;procedure Txc_xs.xc_xsshow(Sender: TObject);
begin
GetAll;
label1.Caption:=???? //显示返回值
end;问题:
1、执行后出现“过程需要参数@zj”的错误,如何将@zj写入代码
2、如何在label1显示返回值
楼主用这个方式试试
ADOStoredProc1.Parameters.CreateParameter('zj',ftFloat,pdInput,4,10);
不过参数pdInput应改为pdOutput
结贴给分