title: ASP return OUTPUT value from sproc
body: <p>How do I return a value from the sproc and assigned it to a variable so that it can be used on the ASP page?</p>
  
  <p>The stored procedure that returns the value is called <code>sp_Auction_PaymentEwayXMLReceive</code>.
  The output variable is called <code>ReturnedMsg</code>.</p>
  
  <p>My current code is: </p>
  
  <pre><code>Dim Connection
  Dim sSQL, sConnString
  sConnString="DRIVER={SQL Server};SERVER=XXXX;UID=XXXX; PWD=XXXX;DATABASE=XXXX;"
      sSQL = "sp_Auction_PaymentEwayXMLReceive '"&eWay.ResultEwayTrxnStatus&"','"&eWay.ResultEwayTrxnNumber&"','"&eWay.ResultEwayTrxnReference&"','"&eWay.ResultEwayTrxnOption1&"','"&eWay.ResultEwayTrxnOption2&"','"&eWay.ResultEwayTrxnOption3&"','"&eWay.ResultEwayAuthCode&"','"&eWay.ResultEwayReturnAmount&"','"&eWay.ResultEwayTrxnError&"' "
      Set sConnection = Server.CreateObject("ADODB.Connection")
      Set connection = Server.CreateObject("ADODB.Connection")
      connection.Open(sConnString)
      connection.execute(sSQL)
  </code></pre>
  
  <p>--EDIT--
  @Andomar</p>
  
  <p>Re Response 1: I have also tried this but I get a 500 error.</p>
  
  <pre><code>
              'set up output parameter
              dim outputParameter
              set outputParameter = _
              cmd.CreateParameter("ReturnedMsg",adVarChar, _
              adParamOutput,40)
  
              'open conn
              connection.Open(sConnString)
  
              'append OUTPUT  
              cmd.Parameters.Append outputParameter   
  
              'exec sql   
              connection.execute(sSQL)
  </code></pre>
  
  <p>-R</p>