>>>>>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?
>>>>
>>>>What's in MyDataAccessClass.ExecuteStoredProcedure() ?
>>>>.
>>>
>>>This is a class that parses parameters (Parameters) and calls a stored procedure (either VFP or SQL Server, depending on the global setting). However, when I created this class I didn't account for the fact that I may need to get some values from OUTPUT parameter. So I will have to modify/refactor this class. Meanwhile, I found that I don't really need the OUTPUT since I will be "dealing" with error via RAISERROR in SQL Server.
>>
>>OK. Just couldn't see what relationship the string arrays had to actual Parameters - and without knowing that there's no way to answer your question :-}
>
>The string array has the following "break-down". 1st element is the name of the parameter passed to the SQL Server stored procedure. 2nd element is the value. 3rd element is (I know it is kludge <g>) is empty string if the value is a string or 'INT" if the value is an integer. So the method ExectueStoredProcedure() parses this array and builds the Parameter collection to be passed to the SP.
Given your previous post I guess you no longer need it but, in pseudo-code:
SqlCommand command = new SqlCommand();
SqlParameter param = new SqlParameter(Parameters[2, 0], Parameters[2, 1]);
param.Direction = ParameterDirection.InputOutput;
command.Parameters.Add(param);
var v = command.Parameters["@Param3"].Value;