G
gxcooo
Unregistered / Unconfirmed
GUEST, unregistred user!
我在D7里用TSQLStoredProc调用MS SQL 2000里的存储过程出错[]
存储过程是:
select @ErrCode=0
if exists(select* from book
where bookid=@bookid and isfree=1)
begin
update book set isfree=0 where bookid=@bookid
insert borrow (bookid,userid,borrowdate) values (@bookid,@userid,GETDATE());
end
else
begin
select @ErrCode=1
end
return @ErrCode
GO
在D7里的调用代码为:
with doborrowSQLStoredProc do
begin
StoredProcName:='doborrow';
Params.Clear;
P1 := TParam.Create(Params, ptInput);
P2 := TParam.Create(Params, ptInput);
try
Params[0].Name := '@userid';
Params[1].Name := '@bookid';
ParamByName('@userid').AsString :=Edit1.Text;
ParamByName('@bookid').AsString :=Edit2.Text;
ExecProc;
finally
P1.Free;
P2.Free;
end;
end;
出错提示见附图: http://kuga.51.net/temp/12.jpg
存储过程是:
select @ErrCode=0
if exists(select* from book
where bookid=@bookid and isfree=1)
begin
update book set isfree=0 where bookid=@bookid
insert borrow (bookid,userid,borrowdate) values (@bookid,@userid,GETDATE());
end
else
begin
select @ErrCode=1
end
return @ErrCode
GO
在D7里的调用代码为:
with doborrowSQLStoredProc do
begin
StoredProcName:='doborrow';
Params.Clear;
P1 := TParam.Create(Params, ptInput);
P2 := TParam.Create(Params, ptInput);
try
Params[0].Name := '@userid';
Params[1].Name := '@bookid';
ParamByName('@userid').AsString :=Edit1.Text;
ParamByName('@bookid').AsString :=Edit2.Text;
ExecProc;
finally
P1.Free;
P2.Free;
end;
end;
出错提示见附图: http://kuga.51.net/temp/12.jpg