There is a difference between parameters and local variables.
When you do this:
foreach (SqlParameter sqp in lsp)
You create a new local variable of the same name as the parameter, and scope it to the
foreach
block.
As a result, your function never assigns a value to the parameter
sqp
- and since it is declared as an
out
parameter the system
requires a value be assigned to it before the method exits, regardless of which path it takes through the method. If any path does not assign a value, you will get an error, and your code will not compile.