get output parameter value in asp

Results 1 to 2 of 2

Thread: get output parameter value in asp

  1. #1
    Join Date
    Dec 1969

    Default get output parameter value in asp

    If I have this stored proc, how do I retrieve the value of @outputparam in my asp page. I use the command object to pass the input param.<BR><BR>--ASP CODE --<BR>With com<BR> .ActiveConnection = con<BR> .CommandType = 4<BR> .CommandText = "dbo.SampleProc"<BR> <BR> .Parameters(1) = icn<BR> .Execute <BR>End With<BR><BR>--STORED PROC --<BR><BR>Create PROCEDURE dbo.SampleProc<BR>@inputparam int,<BR>@outputparam varchar(20) OUTPUT<BR><BR>as<BR><BR>If @inputparam &#062;= 0<BR> begin<BR> ...<BR> set @outputparam = &#039;yes&#039;<BR> end<BR><BR>else<BR> begin<BR> ...<BR> set @outputparam = &#039;no&#039;<BR> end<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: get output parameter value in asp

    You need to define the parameter in the command object and then retrieve the value after the execute call. Something like:<BR><BR>With com<BR>.ActiveConnection = con<BR>.CommandType = 4<BR>.CommandText = "dbo.SampleProc"<BR><BR>.Parameters.Append adocmd.CreateParameter("@inputparameter", _<BR> adInteger, adParamInput, 4, icn)<BR>.Parameters.Append adocmd.CreateParameter("@outputparameter", _<BR> adVarChar, adParamOutput, 20,)<BR><BR><BR>.Execute <BR>output = .Parameters("@outputparameter").value<BR>End With<BR><BR><BR>That&#039;s all from memory, so there might be a few little errors in there, but that&#039;s the main idea.<BR><BR>-Nathan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts