First of all, thank you for answering my query. To answer your question, yes
I did add it to the command object as an output parameter. I also coded the
T-SQL of the store procedure as an output parameter. I genuinely believed I
did everything I had to do to ensure everything works as it's supposed to. I
even had similar code, that works the same way, that works fine. I compared
the code to make sure I did not make any mistakes along the way and
everything seems fine. Here is some sample code that I am using:
SqlParameter[] Parameters;
Parameters = new SqlParameter[2];
Parameters[0] = new SqlParameter("@ shortLinkId", SqlDbType.VarCh ar);
Parameters[0].Value = shortLinkId;
Parameters[1] = new SqlParameter("@ shortLinkUrl", SqlDbType.VarCh ar);
Parameters[1].Direction = ParameterDirect ion.Output;
SqlHelper.Execu teCommand(conne ctionString, "spGetShortLink Url", Parameters);
shortLinkUrl = Parameters[1].Value.ToString ();
The following is some code from the ExecuteCommand method:
SqlCommand Command = new SqlCommand();
Command.Connect ion = new SqlConnection(c onnection);
Command.Command Text = commandText;
Command.Command Type = commandType;
foreach (SqlParameter parameter in commandParamete rs)
Command.Paramet ers.Add(paramet er);
Command.Connect ion.Open();
int recordsAffected ;
try
{
recordsAffected = Command.Execute NonQuery();
}
catch (Exception ex)
..
..
..
Thanks,
Hector
"Wilco Bauwer" wrote:
Did you add it as an output parameter to the parameters collection of
the command you are executing? You can do so by setting the parameter's
Direction to ParameterDirect ion.Output.
----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl