title: Return value from stored procedure
body: <p>Hi I am using vs 2008 doing a winforms app in vb.net. I have a database with a single table, that has two columns, in it and a stored procedure. The stored procedure is supposed to take an input value, match that value against one column in the table and then return the corresponding value from the other column; except it doesnt.It returns 1 or 0 please can anyone tell me why</p>
  
  <pre><code>ALTER PROCEDURE dbo.getgamenumber(@outputnumber bigint OUTPUT,
                                    @inputnumber bigint) 
  AS 
  
    SELECT @outputnumber = ggnumber
      FROM statstable
     WHERE gindex = @inputnumber 
  
    RETURN  @outputnumber
  </code></pre>
  
  <p>and the stored proc is called thus </p>
  
  <pre><code>With cmdgetgame
    .CommandType = CommandType.StoredProcedure
    .CommandText = "getgamenumber"
    .Parameters.Add("@outputnumber", SqlDbType.BigInt).Value = outputnumber
    .Parameters("@outputnumber").Direction = ParameterDirection.Output
    .Parameters.AddWithValue("@inputnumber", inputvalue)
    returnvalue = cmd.ExecuteScalar()
  End With
  </code></pre>
  
  <p>Thanks for all and any help.   </p>
  
  <p>sorry for the confusion my vb code now looks like this</p>
  
  <pre><code> With cmdgetgame
                  .CommandType = CommandType.StoredProcedure
                  .CommandText = "getgamenumber"
                  .Parameters.Add("@outputnumber", SqlDbType.BigInt).Value = outputnumber
                  .Parameters("@outputnumber").Direction = ParameterDirection.Output
                  .Parameters.AddWithValue("@inputnumber", inputvalue)
                  cmd.ExecuteNonQuery()
                  returnvalue = cmdgetgame.Parameters("@outputnumber").Value
              End With
  </code></pre>
  
  <p>and my stored proc like this</p>
  
  <pre><code>ALTER PROCEDURE dbo.getgamenumber
  ( @outputnumber bigint ,
  @inputnumber bigint) 
  AS 
      SELECT       ggnumber
      FROM            statstable
      WHERE        (gindex = @inputnumber)
  </code></pre>
  
  <p>but  I still dont get the value I expect. </p>