ParameterDirection Enumeration

Hi all,

This enumeration has the following values (from help) ...

Description
Input The parameter is an input parameter.
InputOutput The parameter is capable of both input and output.
Output The parameter is an output parameter.
ReturnValue The parameter represents a return value from an operation such as a stored procedure, built-in function, or user-defined function.

I'm not clear on the difference between Output and ReturnValue. I'm using a stored procedure (which works fine within SQL Server Management Console) to create a row and return the generated ID. When I call from a C# Web Service I get an error that I have a missing Parameter (the ID to be returned).


Answer this question

ParameterDirection Enumeration

  • christian bitter

    Many thanks. MUCH more helpful than the help text !
  • Surfsune

    One big difference is that you can only have one return value, while you can have many Output values:

    Heres an exaple of a ReturnValue SP:
    In ADO.net you would add a parameter @user_id with ReturnValue Enum

    CREATE PROCEDURE usp_checkuser

    @login varchar(50),

    @pswd varchar(50),

    @usr_id int

    AS

    SET @usr_id = (SELECT id FROM USRS

    WHERE login=@login

    AND pswd=@pswd)

    RETURN @usr_id

    GO

    Now the same one using output parms, but I can use more output parms than return parms:
    In ADO.net you would add a parameter @user_id with Output Enum and
    a parameter @lastlogin with Output Enum

    CREATE PROCEDURE usp_checkuser

    @login varchar(50),

    @pswd varchar(50),

    @usr_id int output,

    @lastlogin smalldatetime output

    AS

    DECLARE @id int

    DECLARE @laslogin smalldatetime

    SELECT @id = id, @laslogin=lastlogin FROM USRS

    WHERE login=@login

    AND pswd=@pswd

    SET @usr_id = @id

    SET @lastlogin = @login

    GO


    Also RETURN can only return integer values.. while output can be varchar, date etc.

  • ParameterDirection Enumeration