sqlcommand - C# - Output SqlParameter uses different values then the ones given? -


I have a SqlCommand that runs a stored procedure that contains two integer output parameters SqlCommand before running I can see The output parameters are set to the correct value, however, when the command actually executes, then parameter 1 and 0 use a tap for the parameter 2 (verified using SQL Profiler).

A simplified version of the code is:

  foreach (keyvaluePair & quot; output parameters in the string, object & gt; parameter} {SqlParameter param = new SqlParameter (parameter Parameter.Value); Param.Direction = Parameter Direction. Output; Command.Parameters.Add (Ultimate); } Command.ExecuteNonQuery ();  

I am confused with two different things here:

1) Why does not it use values ​​in the parameter? I can put a breakpoint before command.ExecuteNonQuery () and I can see that the command The output parameters are set correctly in the parameter list, even when the SQL Profiler Trace has different parameters when the query is executed.

2) Both parameters are integers and exact are defined in the same way - why is one set on tap whereas other set 0?

They output parameter - i.e. meaning to stored procedure ... logically they do not have the is value on the input If you want the value used by the client in the stored procedure, then they have the InputOutput Should be the direction of

Edit: Answer your comment - Output means bus output input means bus Input Input Output means both ways that you want both ways, so use InputOutput .

This is the reason why one is null and not others ... I do not know, to be honest is to be honest. / P>


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -