I am getting error for the below code. I am passing local ids as "113332,113347"
cn.Open();
SqlCommand cmd = new SqlCommand("SelectUser", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@in_UserId", SqlDbType.Int).Value = Convert.ToInt32(userId);
cmd.Parameters.Add("@in_StartDate", SqlDbType.DateTime).Value = fromDate;
cmd.Parameters.Add("@in_EndDate", SqlDbType.DateTime).Value = toDate;
cmd.Parameters.Add("@in_LocalIds", SqlDbType.NVarChar, 100).Value = localids.ToString();
cmd.ExecuteNonQuery();
"Conversion failed when converting the nvarchar value '113332,113347' to data type int."
In database, the local id is of datatype int.
The stored procedure code is given below
CREATE PROCEDURE [dbo].[User_Update] @in_UserId INT
,@in_StartDate DATETIME
,@in_EndDate DATETIME
,@in_LocalIds NVARCHAR(100)
AS
BEGIN
SELECT * FROM TABLE1 WHERE LocalId in (@in_LocalIds) AND UserId = @in_UserId
END
go