title: Getting return value from stored procedure in VB.NET
body: <p>I have the following stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[BK_NUMBER]
      (@Category NUMERIC(38, 0)) 
  WITH EXECUTE AS CALLER
  AS
     DECLARE @RunningNumber Int
     DECLARE @min Int
     DECLARE @max Int
     DECLARE @newRunningNumber Int
  
     BEGIN
  
        SELECT @RunningNumber = RunningNumber
        FROM PARKMARKENNUMMER
        WHERE PARKMARKENTYP_ID = @Category
  
        UPDATE PARKMARKENNUMMER 
        SET RUNNINGNUMBER = @RunningNumber + 1
        WHERE PARKMARKENTYP_ID = @Category 
  
        SELECT @newRunningNumber = RunningNumber
        FROM PARKMARKENNUMMER 
        WHERE PARKMARKENTYP_ID = @Category 
  
        RETURN @newRunningNumber;
  End;
  </code></pre>
  
  <p>I try to get <code>@newRunningNumber</code> with this VB code:</p>
  
  <pre><code> Dim sqlConnection As New SqlConnection(MSSQL_Helper.strConnectionBookit)
          Dim command As New SqlCommand("BK_NUMBER", sqlConnection)
          command.CommandType = CommandType.StoredProcedure
          command.Parameters.Add("@Category", SqlDbType.Int).Value = ID
          Dim returnParameter As SqlParameter = command.Parameters.Add("RetVal", SqlDbType.Int)
          returnParameter.Direction = ParameterDirection.ReturnValue
          sqlConnection.Open()
          command.ExecuteNonQuery()
          sqlConnection.Close()
          Dim returnValue As Integer = returnParameter.Value
          Return returnValue
  </code></pre>
  
  <p>But it returns always "0". What am I doing wrong? </p>