I have a stored procedure in SQL server that returns 0
at the end as shown:
create procedure myProc
as
begin
select * from sampleTable
return 0
end
This value is returned as expected when calling the stored procedure from sql:
exec @i = myProc
select @i -- value is 0
I call the procedure in C# like this:
SqlDataReader dr = await CommandObj.ExecuteReaderAsync(CommandBehavior.SequentialAccess, token).ConfigureAwait(false);
However, when attempting to read this value in C#, the value of the parameter with ParemeterDirection.ReturnValue
is null.
Interestingly, the code above works for procedures that do not select a datatable. Sample code that works:
await CommandObj.ExecuteNonQueryAsync(token).ConfigureAwait(false);
followed by same code to read the ReturnValue. I would like to specifically use a ReturnValue, not an out
parameter.
Any ideas?