Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:46:43+00:00 2026-05-27T00:46:43+00:00

I am using ASP classic with ADO, connecting to SQL Server 2008. I inherited

  • 0

I am using ASP classic with ADO, connecting to SQL Server 2008.

I inherited this code and it is so mangled that I will try to recreate the relevant parts. If you need more detail or I left something out, please let me know.

I create a command and add parameters

oCmd.CommandType = adCmdStoredProc
...
oCmd.Parameters.Append oCmd.CreateParameter("@MyOutputParam", adInteger, adParamOutput, 4, NULL)

Later, I open a reader from that command:

oRS.Open oCmd, , adOpenForwardOnly, adLockReadOnly

After that, while oRS is open but before I’ve read any records or values, I try to get the output parameter’s value using one of the lines below:

val1 = oCmd("@MyOutputParam")
val2 = oCmd("@MyOutputParam").Value
val3 = oCmd.Parameters("@MyOutputParam").Value

All three (val1, val2, val3) variables are DB NULL.

I have confirmed that running the SP in query analyzer returns a value to the @MyOutputParam parameter:

declare @p33 int
exec usp_GetResultAndOutput 1, 2, 3, @p33 output
select @p33

That returns a recordset of my expected records and a second recordset showing a number in a single row.

I’ve even tried calling rs.NextRecordset before attempting to get the output parameter and that didn’t work.

Is there some other way that I need to be handling Output parameters?

Is it okay that I am returning a recordset and output parameters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:46:43+00:00Added an answer on May 27, 2026 at 12:46 am

    Output parameters cannot be retrieved until all the recordsets are enumerated until the end. Just think, how could the client possibly retrieve the output value of a parameter before the execution finishes? The Execute() call is simply starting the execution, the batch continues to execute on the server until all results are returned. While a client is iterating over a resultset produced by a SELECT the batch is executing that SELECT. The value of the output parameter is known only at the end of the batch. Therefore is not possible to know the output parameter value until the batch finished, which implies that all statements have executed, which in turn requires that all resultsets were consumed (iterated) by the client.

    This is the canonical form of parsing a set of results:

    do
    {
      while (rs.MoveNext)
      {
        // do something with the row
      }
    } while (Not rs.NextRecordset Is Nothing)
    // now is safe to read the out param
    response.write oCmd("@MyOutput")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Classic asp and SQL Server 2005. This is code that works
I'm using VBScript (ASP Classic) and SQL Server; I'm trying to have a section
I'm using visual studio 2008 for a classic asp application. Will I be able
Using classic asp, I am trying to query a SQL Server database like so:
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
i am trying to load a aspx in a classic asp using this code:
I'm using classic asp, I have a drop down list that the user selects
I'm trying to update an NText field in SQL 2000 using Classic ASP. Here
I'm using Server.HtmlEncode on a utf-8 string in asp-classic, which works fine until there
I'm using an ASP classic server, with JavaScript as the language engine, specified by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.