Retreive Output Parameter

  • I am calling a SP from a C# web method.

    I am not sure how to finish this up to retrieve the output parameter.

    this is the web method:

    int IndexOut = 0; //this will be the returned integer

    SqlConnection myConnection = new SqlConnection(sConnect);

    SqlDataAdapter myCommand1 = new SqlDataAdapter ("SP_ADD_NEW_TEMPLATE", myConnection);

    myCommand1.SelectCommand.CommandType = CommandType.StoredProcedure;

    myCommand1.SelectCommand.Parameters.Add("@YEAR", SqlDbType.DateTime ).Value = dtyear;

    myCommand1.SelectCommand.Parameters.Add("@DIV", SqlDbType.Int ).Value = idiv;

    myCommand1.SelectCommand.Parameters.Add("@JOB", SqlDbType.Int ).Value = ijob;

    myCommand1.SelectCommand.Parameters.Add("@GRADE", SqlDbType.Int ).Value = igrade;

    myCommand1.SelectCommand.Parameters.Add("@creatorID", SqlDbType.Int ).Value = icreatorID;

    myCommand1.SelectCommand.Parameters.Add("@Description", SqlDbType.Char).Value = cdescription;

    myCommand1.SelectCommand.Parameters.Add("@superVisorID", SqlDbType.Int ).Value = isupervisorID;

    myCommand1.SelectCommand.Parameters.Add("@bOverWrite", SqlDbType.Bit ).Value = bOverWrite;

    myCommand1.SelectCommand.Parameters.Add("@@IndexOut", SqlDbType.Int ).Value = IndexOut;

    this is the procedure header

    CREATE PROCEDURE [dbo].[SP_ADD_NEW_TEMPLATE](@year DATETIME, @div INT, @job INT, @grade INT,

    @creatorID INT, @Description varchar(1000), @superVisorID INT, @bOverWrite BIT, @@IndexOut Int output)

  • in the proc define the output param with single @ as in

    @IndexOut Int output

    when you want to refer to the output use

    myCommand1.SelectCommand.Parameters("@IndexOut").Value  

    Edited by - davidburrows on 11/05/2003 07:13:37 AM

    Far away is close at hand in the images of elsewhere.
    Anon.

  • thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply