Dynamic multi-dimentional arrays in VBScript

Need a Dynamic multi-dimentional array to load items from a database.
Example:
  ...
  dim tempArray()
  length1 = 1
  Set RS = MyConn.Execute(strSQL)
  while not RS.eof
    redim preserve tempArray(length,4)
    ...
    length = length + 1
  wend

But keep getting error:

  Subscript out of range

indicating the redim line.

When trying to declare a multi-dimentional array with a variable,
Example:
  dim temp2Array(length,4)
 
I get the error message:
  Expected integer constant

  /TemplateTesting/sendNewsletter2.asp,   line 75

  dim temp2Array(length,4)
  ---------------^

So it requires a constant!!  How can I get round this problem.  I have a database items, each with a dimention of four items which change from day to day depending on additions and deletions... so I need an array with a dynamic length and four dimentions.

thegurns






thegurnsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deightonprogCommented:
you can only change the size of the last dimension wirth redim

You have to make it (4,length)

i.e swap rows with columns
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deightonprogCommented:
Your restriciton is with the preserve keyword - otherwise you can redim (but lose the data)

This works though


                      dim tempArray()
                      length1 = 1
                      Set RS = MyConn.Execute(strSQL)
                      while not RS.eof
                        redim preserve tempArray(4,length)
                        ...
                        length = length + 1
                      wend
0
thegurnsAuthor Commented:
Thank you deighton... but what a palova!!!  Don't make it easy do they??
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.