我创建了一个存储过程:
ALTER PROCEDURE [dbo].[Budget_Details]
@Budget_Type varchar(10)
,@Item_Category_Code varchar (20)
,@Item_Description varchar(500)
,@Configurations varchar(500)
,@Project varchar(100)
,@Budgeted_Qty numeric(9,2)
,@Reason_for_Budgeted_Cost numeric(9,2)
,@Total_Cost numeric(9,2)
,@Action varchar(10)
,@B_Number varchar(10)
AS
IF @Action='ADDNEW'
BEGIN
DECLARE @Budget_Number varchar(30)
DECLARE @Budget_FY_Code varchar(10)
DECLARE @seqNo AS integer
SELECT @seqNo=ISNULL(Budget_Num,0) FROM Seq_Master
SET @seqNo=@Budget_FY_Code+@seqNo+1
SET @Budget_Number=@seqNo
PRINT @Budget_Number
INSERT Budget_Master
(
Budget_Number
,Budget_FY_Code
,Budget_Type
,Item_Category_Code
,Item_Description
,Configurations
,Project
,Budgeted_Qty
,Reason_for_Budgeted_Cost
,Total_Cost
)
VALUES
(
@Budget_Number
,@Budget_FY_Code
,@Budget_Type
,@Item_Category_Code
,@Item_Description
,@Configurations
,@Project
,@Budgeted_Qty
,@Reason_for_Budgeted_Cost
,@Total_Cost
)
UPDATE Seq_Master SET Budget_Num=@seqNo
END
ELSE IF @Action='EDIT'
BEGIN
UPDATE Budget_Master
SET
Budget_FY_Code=@Budget_FY_Code
,Budget_Type=@Budget_Type
,Item_Category_Code=@Item_Category_Code
,Item_Description=@Item_Description
,Configurations=@Configurations
,Project=@Project
,Budgeted_Qty=@Budgeted_Qty
,Reason_for_Budgeted_Cost=@Reason_for_Budgeted_Cost
,Total_Cost=@Total_Cost
WHERE
Budget_Number = @B_Number
END
但它不起作用,没有 seqNo 在执行时生成,并且想知道如何在 C# 中为 Web 表单使用这个存储过程