I am trying to get a value from a stored procedure:
SET @RowCount = @@RowCount
IF @RowCount = 1 BEGIN SET @Ret = 1 PRINT 'Insert a success' END
IF isnull(@RowCount,0) = 0 BEGIN SET @Ret = 2 PRINT 'Insert a failure.. Terminating Proc...' RETURN END
I should be getting a 1 or 2, but keep getting a 0 with this code:
cmd.Parameters.Add("@Ret", SqlDbType.Int);
cmd.Parameters["@Ret"].Direction = ParameterDirection.ReturnValue;
conn.Open();
int ReturnedVal=1;
cmd.ExecuteNonQuery();
ReturnedVal = (int)cmd.Parameters["@Ret"].Value;
conn.Close();
CountCheck.Text = Convert.ToString(ReturnedVal);
I would really like to get the printed statements, but will settle for anything at this point. :)