I am trying to get data returned from my stored procedure. This is what I have tried and absolutely nothing is coming back.
Stored Proc:
Declare @Submit_
You're not adding the return parameter to the command:
SqlParameter pSub = new SqlParameter("@Sub_ID", SqlDbType.Int);
pSub.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(pSub); // <------------- add to command
conn.Open();
cmd.ExecuteNonQuery();
subid = Convert.ToInt32(cmd.Parameters["pSub"].Value);
First add parameter to cmd
and use .Value
to its value
cmd.Parameters.Add(pSub); // add parameters to command
cmd.ExecuteNonQuery();
subid = Convert.ToInt32(pSub.Value); // Use .Value