存储过程和ASP .NET

时间:2014-05-20 15:58:58

标签: sql-server stored-procedures

我在sql server上创建了一个用于更新记录的存储过程,当我插入所需的参数时它工作正常...但是当我在ASPX GridView上按更新时运行应用程序时它是ASP .NET它给我一个消息 "过程或函数custUPDATE指定了太多参数。"

这是我的程序的代码

   alter proc custUPDATE
( @odid int, 
  @customer_id int,
  @priceID int,
  @etAMOUNT int,
  @amntPaid decimal(18,2),
  @od_status varchar(20),
  @py_status varchar(20),
  @order_date smalldatetime
 -- @dummy varchar(30) =null
  )
as 
begin
set nocount on;
declare @amnt_paid decimal(18,2);
declare @rmn decimal(23,4);
declare @tt money;

select @amnt_paid=eggsOrders.amnt_paid from eggsOrders where od_ID=@odid;
select @rmn= orderVIEW.Remaining from orderVIEW where od_ID=@odid;
select @tt=orderVIEW.Total from orderVIEW where od_ID=@odid;
--select @amnt_paid= amnt_paid from inserted;



if(@amnt_paid=@tt)
begin
update [dbo].[eggsOrders] set customer_ID=@customer_id, price_ID=@priceID, ET_amount=@etAMOUNT, amnt_paid=@amntPaid, Od_status=@od_status, py_status='paid in full', order_date=@order_date where od_ID=@odid;

end

else if(@amnt_paid>0 and @amnt_paid!=@tt)
begin
update [dbo].[eggsOrders] set customer_ID=@customer_id, price_ID=@priceID, ET_amount=@etAMOUNT, amnt_paid=@amntPaid, Od_status=@od_status, py_status='In-Progress', order_date=@order_date where od_ID=@odid

end
else if(@amnt_paid=0 and @rmn =@tt)
begin
update [dbo].[eggsOrders] set customer_ID=@customer_id, price_ID=@priceID, ET_amount=@etAMOUNT, amnt_paid=@amntPaid, Od_status=@od_status, py_status='Payment Pending', order_date=@order_date where od_ID=@odid

end


end
go

我做错了什么? 请帮忙

2 个答案:

答案 0 :(得分:1)

错误是明确的:您将更多参数传递给方法而不是预期,从而导致错误。仔细检查您在SP调用中传递的参数数量。

答案 1 :(得分:0)

我偶尔会注意到,即使在SQL Server上进行了更改,ASP.NET也会在Visual Studio中缓存旧的SPROC。例如,您通过添加参数更改了custUPDATE,并将参数添加到ASP.NET代码中,但仍然收到“指定的arguemtns数太多”错误,因为旧的SPROC正在缓存。

如果是这种情况,我会尝试以下方法:

将ASP.NET页面中的SPROC名称从custUPDATE更改为[custUPDATE],然后尝试运行它。