为 adostroredproc 指定两个参数时出错(delphi5.0+win2000p) (100分)

  • 主题发起人 brucedai
  • 开始时间
B

brucedai

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
begin
adoconnection1.Connected:=true;
adodataset1.Active:=true;
adodataset2.active:=true;
adodataset1.First;
form1.caption:=inttostr(adodataset2['id']);
while not adodataset1.Eof do
begin
adodataset2.First;
while not adodataset2.eof do
begin

if adodataset1['名称']=adodataset2['name'] then
begin
adostoredproc1.Close;

adostoredproc1.Parameters.Paramvalues['@uid']:=adodataset2['id'];
adostoredproc1.Parameters.ParamValues['@akeyid']:=strtoint(adodataset1['roleid']);

adostoredproc1.Prepared;
adostoredproc1.ExecProc;
break;
end;
adodataset2.next
end ; //form1.caption:=inttostr(adodataset1.RecordCount);
adodataset1.Next
end;
end;

运行到adostoredproc1.execproc 是系统提示‘为过程指定的参数过多’,
请问各位这是怎么回事?
代码:
 
把存储过程贴出来看看
 
存储过程如下:
CREATE PROCEDURE [dbo].[AddRole]
@uid int,@akeyid int as
insert into userkeyvalue (userid,keyvalueid) values(@uid,@akeyid)
GO
 
我知道为什么了 我把adostoredproc 自带的@returnvalue 参数去掉就可以了
 
其實如果你用adostoredproc1.Parameters[1]:=adodataset2['id'];
adostoredproc1.Parameters[2]:=strtoint(adodataset1['roleid']);
就可以避免自己去去掉@returnvalue 参数!
 
顶部