这是我的功能:
create function fn_Inventory(@qty int, @item_ID int)
returns int
as begin
declare @result int
set @result = (SELECT Quantity - @qty from Items where @item_ID = item_ID)
return @result
end
我想从我的asp.net代码执行此函数;怎么做?
答案 0 :(得分:0)
public int TotalCupom(int qty,int item_ID)
{
int result;
SqlDataAdapter da2 = new SqlDataAdapter();
if (conex1.State == ConnectionState.Closed)
{ conex1.Open();}
SqlCommand Totalf = new SqlCommand("SELECT dbo.fn_Inventory(@qty,@item_ID)", qty,item_ID);
SqlParameter _qty= new SqlParameter("@qty", SqlDbType.Int);
SqlParameter _item_ID= new SqlParameter("@item_ID", SqlDbType.Int);
_qty.Value = qty;
_item_ID.Value = item_ID;
result= Totalf.ExecuteScalar();
return result;
}