Hi,
According to your coding, you won't be able to get parameter value i.e. "value21", because "value22" is replacing the previous value of your parameter. You can use individual parameters to get and set bot parameters. Use this:
If you can use two parameters in your SP:
var parametertaxitem1 = new SqlParameter("@taxitemid1", SqlDbType.Int, (50));
parametertaxitem1.Value = valu121;
myCommand.Parameters.Add(parametertaxitem1);
var parametertaxitem2 = new SqlParameter("@taxitemid2", SqlDbType.Int, (50));
parametertaxitem2.Value = value22;
myCommand.Parameters.Add(parametertaxitem2);
If you are using only one parameter:
Concatenate the strings using special character and split it in your stored procedure. Like:
var parametertaxitem = new SqlParameter("@taxitemid", SqlDbType.Int, (50));
parametertaxitem.Value = valu121.ToString()+"±"+value22.ToString();
myCommand.Parameters.Add(parametertaxitem);
Now you are receiving both the values. Just split it in your stored procedure and use it. Like:
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ETIPSAVE_SP]
@taxitemid int ,
@empid int,
@amount int ,
@Etid int OUTPUT
AS
BEGIN
DECLARE @taxitemid1 VARCHAR(10)
DECLARE @taxitemid2 VARCHAR(10)
SET @taxitemid1 = substring(@val, 0, charindex('±', @taxitemid ))
SET @taxitemid2 = substring(@val, charindex('±', @taxitemid)+1, LEN(@taxitemid))
INSERT INTO Employee_Tax_item_Payroll ( tax_item_id, emp_id, amount ) VALUES ( @taxitemid1, @empid , @amount ), ( @taxitemid2, @empid , @amount )
SELECT @etid = @@Identity
END
All the best.
--Amit