Help! Storing Arrays in Session Variables - problem 
Author Message
 Help! Storing Arrays in Session Variables - problem

I have an ASP script in which I'm loading an array called "arrRATES1" from a
database, then storing this array in a Session variable so that the database
doesn't need to be accessed each time the user refreshes.

I am trying this the same way the example in "Professional Active Server
Pages 2.0"
does it (p.333); it seems to place the array into the session variable o.k.,
but when I
refresh the page and it tries the reverse, it bombs with:

Quote:
>--8

Microsoft VBScript runtime error '800a000d'

Type mismatch

/Function_library_us.vjp.asp, line 620 "

Quote:
>--8

This is the code, with the offending line noted:

Quote:
>--8

'Load annuity table array ONLY first time through:
if session("tables_loaded") = false then
   call LOAD_RATES1_TABLE
   session("StoredRATES1") = arrRATES1
   session("tables_loaded") = true
else
   arrRATES1 = session("StoredRATES1")
<------- line 620
end if

Quote:
>--8

....any ideas?   arrRATES1 is dimensioned (n,4) where n = the number of rows
retrieved from the table.
If is DIM'med at the beginning of the script with "dim arrRATES1()", and
REDIM'med in the LOAD_RATES1_TABLE
sub with "redim arrRATES1(n,4)".   Could the two-dimensional aspect be
causing this problem?

Thanks for any help......



Sun, 19 May 2002 03:00:00 GMT  
 Help! Storing Arrays in Session Variables - problem

Dim it as a simple variant variable, not as a dynamic array.  You _can_ ReDim it even if it isn't Dim'd originally as a dynamic array, but you _can't_ use Preserve the 1st time it's ReDim'd if it's a simple variant variable to start with.

If it is Dim'd already as a dynamic array, then you can't assign the saved array back to it.  The VBScript engine expects _all_ references to arrRATES1 to include indices when the are on the left hand side of an assignment statement.

--
Michael Harris

  I have an ASP script in which I'm loading an array called "arrRATES1" from a
  database, then storing this array in a Session variable so that the database
  doesn't need to be accessed each time the user refreshes.

  I am trying this the same way the example in "Professional Active Server
  Pages 2.0"
  does it (p.333); it seems to place the array into the session variable o.k.,
  but when I
  refresh the page and it tries the reverse, it bombs with:

  >--8
  Microsoft VBScript runtime error '800a000d'

  Type mismatch

  /Function_library_us.vjp.asp, line 620 "
  >--8

  This is the code, with the offending line noted:

  >--8
  'Load annuity table array ONLY first time through:
  if session("tables_loaded") = false then
     call LOAD_RATES1_TABLE
     session("StoredRATES1") = arrRATES1
     session("tables_loaded") = true
  else
     arrRATES1 = session("StoredRATES1")
  <------- line 620
  end if
  >--8

  ....any ideas?   arrRATES1 is dimensioned (n,4) where n = the number of rows
  retrieved from the table.
  If is DIM'med at the beginning of the script with "dim arrRATES1()", and
  REDIM'med in the LOAD_RATES1_TABLE
  sub with "redim arrRATES1(n,4)".   Could the two-dimensional aspect be
  causing this problem?

  Thanks for any help......



Sun, 19 May 2002 03:00:00 GMT  
 Help! Storing Arrays in Session Variables - problem

Aha!   Thank you!


  Dim it as a simple variant variable, not as a dynamic array.  You _can_ ReDim it even if it isn't Dim'd originally as a dynamic array, but you _can't_ use Preserve the 1st time it's ReDim'd if it's a simple variant variable to start with.

  If it is Dim'd already as a dynamic array, then you can't assign the saved array back to it.  The VBScript engine expects _all_ references to arrRATES1 to include indices when the are on the left hand side of an assignment statement.

  --
  Michael Harris

    I have an ASP script in which I'm loading an array called "arrRATES1" from a
    database, then storing this array in a Session variable so that the database
    doesn't need to be accessed each time the user refreshes.

    I am trying this the same way the example in "Professional Active Server
    Pages 2.0"
    does it (p.333); it seems to place the array into the session variable o.k.,
    but when I
    refresh the page and it tries the reverse, it bombs with:

    >--8
    Microsoft VBScript runtime error '800a000d'

    Type mismatch

    /Function_library_us.vjp.asp, line 620 "
    >--8

    This is the code, with the offending line noted:

    >--8
    'Load annuity table array ONLY first time through:
    if session("tables_loaded") = false then
       call LOAD_RATES1_TABLE
       session("StoredRATES1") = arrRATES1
       session("tables_loaded") = true
    else
       arrRATES1 = session("StoredRATES1")
    <------- line 620
    end if
    >--8

    ....any ideas?   arrRATES1 is dimensioned (n,4) where n = the number of rows
    retrieved from the table.
    If is DIM'med at the beginning of the script with "dim arrRATES1()", and
    REDIM'med in the LOAD_RATES1_TABLE
    sub with "redim arrRATES1(n,4)".   Could the two-dimensional aspect be
    causing this problem?

    Thanks for any help......



Sun, 19 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Storing JScript Arrays in a Session Variable

2. storing a 2 dimensional array in a session variable

3. Storing arrays in a Session Variable

4. Passing Array to Session Variable Then back to Array

5. Splitting Session Variable into several variables (array?)

6. Passing names of arrays stored in session object to function

7. Server side JScript objects stored in Session variables

8. Class Objects stored into session variables, not possible?

9. Can VBScript classes be stored as Session variables?

10. Storing objects in ASP session variables

11. Storing arrays/objects in application variables

12. Problem with a session variable containing a stored array.

 

 
Powered by phpBB® Forum Software