I'm working on an app written in C# (VS2013). It's calling a stored procedure in SQL Server. It's passing a bunch of input parameters, plus four output parameters.
My problem is that one of these output parameters is getting passed with a value that I'm not setting.
This is what SQL Server Profiler records as the procedure call. I've replaced the actual parameter names with generic names just for asking this question.
declare @p51 int
set @p51 = 300000
declare @p52 int
set @p52 = NULL
declare @p53 int
set @p53 = 7776
declare @p54 int
set @p54 = NULL
exec [dbo].[proc_name] (input param list is here)
@outparam1 = @p51 output, @outparam2 = @p52 output,
@outparam3 = @p53 output, @outparam4 = @p54 output
@outparam3/@p53
is the issue. It shouldn't have a value. It's being created with a null value like this (even though as an output parameter that shouldn't be necessary):
var spParam3 = new SqlParameter("@outparam3", SqlDbType.Int);
spParam3.Value = DBNull.Value;
There's nothing between that line of code, and the stored procedure execution, that's setting a different value for the parameter. I've set a breakpoint on the ExecuteNonQuery()
call, checked the parameter list, and that parameter was still null.
I'm completely lost on why its value is getting set to 7776. Yes, that number is a code used throughout the app, but I can't tell how or why this parameter is getting set to that value.
Any thoughts on where this is happening would be greatly appreciated.