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

  • Home
  • SEARCH
  • 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 3612114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:57:34+00:00 2026-05-18T21:57:34+00:00

I’m trying to fix an ASP Classic app and when I try to create

  • 0

I’m trying to fix an ASP Classic app and when I try to create an array from a Recordset Object. However I Can’t get it to work correctly.

This code gives me a single record (the last one), but as far as I can see it is correct:

Dim Products
Dim Products_cmd
Dim Products_numRows

Set Products_cmd = Server.CreateObject ("ADODB.Command")
Products_cmd.ActiveConnection = Conn
Products_cmd.CommandText = "SELECT prod_id, prod_description FROM dbo.products ORDER BY prod_description ASC" 
Products_cmd.Prepared = true

Set Products = Products_cmd.Execute
Products_numRows = 0

Dim arrProducts()
arrProducts = Products.GetRows()

Using this code gives me an “Subscript out of range: ‘UBound’

Dim Products
Dim Products_cmd
Dim Products_numRows

Set Products_cmd = Server.CreateObject ("ADODB.Command")
Products_cmd.ActiveConnection = Conn
Products_cmd.CommandText = "SELECT prod_id, prod_description FROM dbo.products ORDER BY prod_description ASC" 
Products_cmd.Prepared = true

Set Products = Products_cmd.Execute
Products_numRows = 0
Dim arrProducts()
Dim counter

For counter = 0 to Products.RecordCount - 1
    ReDim Preserve arrProducts(counter,2)
    arrProducts(counter,0) = Products.Fields.Item("prod_id").Value
    arrProducts(counter,1) = Products.Fields.Item("prod_description").Value
    Products.MoveNext
Next
Response.Write(Str(UBound(arrProducts)))

Any ideas would be GREATLY appreciated…

  • 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-18T21:57:34+00:00Added an answer on May 18, 2026 at 9:57 pm

    Your are almost there, the problem is that GetRows() returns a 2 dimensional array, and you need to tell Ubound what dimension do you want.

    Working code:

    Dim Products
    Dim Products_cmd
    Dim Products_numRows
    
    Set Products_cmd = Server.CreateObject ("ADODB.Command")
    Products_cmd.ActiveConnection = Conn
    Products_cmd.CommandText = "SELECT prod_id, prod_description FROM dbo.products ORDER BY prod_description ASC" 
    Products_cmd.Prepared = true
    
    Set Products = Products_cmd.Execute
    
    Dim arrProducts
    arrProducts = Products.GetRows()
    
    dim i
    response.write "<table>"
    For i = 0 to ubound(arrProducts, 2)
       response.write "<tr>"
       response.write("<td>" + trim(i+1))
       response.write("<td>" + trim(arrProducts(0,i)))
       response.write("<td>" + trim(arrProducts(1,i)))
    next
    response.write "</table>"
    %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.