Reputation: 3129
I was wondering how to get the output of a stored procedure without doing it the long way, the long way I am referring to is..
SqlParameter productidparam;
productidParam = cmAddProduct.Parameters.Add("@TheProductID", SqlDbType.Int);
productidParam.Direction = ParameterDirection.Output;
instead I am trying to get the output with overloading like this...
cm.Parameters.Add(new SqlParameter("@TheProductID", SqlDbType.Int)).Direction = ParameterDirection.Output;
with the long way I know I can get the proc output with
string myproductidparam;
myproductidparam = productidparam.Value.ToString();
but how do I get the output with the shorter statement?
Thanks
Upvotes: 1
Views: 80
Reputation: 152644
You could pull the parameter from the command by name:
myproductidparam = Convert.ToInt32(cm.Parameters["@TheProductID"].Value);
Upvotes: 3