>>Hi,
>>
>>I need to get the value of OUTPUT parameter passed to a SQL Server stored procedure from a C# method. The pseudo code is as following:
>>
>>
>>// create array of parameters to pass to the stored proced
>>string[,] Parameters = new string[,] { { "@Param1", cVal1, "" }, { "@Param2", cVal2, "" },
>>{ "@Param3", cVal3, "" } };
>>
>>// call stored procedure:
>>MyDataAccessClass.ExecuteStoredProcedure("MyStoredProcedure", Parameters);
>>
>>
>>
>>Note that the stored procedure will have OUTPUT set to parameter @Param3.
>>
>>My question is, after I execute the procedure above, will the variable @Param3 have the value the procedure will set to? That is, can I, after the procedure do the following:
>>
>>
>>IF (@Param3 = 'SomeString)
>>{
>> // code
>>}
>>
>>
>>My concern (question) is, can I (or should I) refer to the variable as @Param3 in the C# method?
>>
>>TIA.
>
>The Parameters collection should have a value of the output parameter (don't forget to set direction InputOutput for it)
>
>Parameters[2].Value
I am not sure I understand what you mean by "set direction". I thought that if - inside the stored procedure - I declare the 3rd parameter with OUTPUT that is all that is necessary.
That is, in stored procedure I will have
PROCEDURE MyProc
@cSomeParamName VARCHAR(20),
@cSomeParamName2 VARCHAR(20),
@cSomeParamName3 VARCHAR(30) OUTPUT
Is the above correct?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham