session variables and arrays

Discussion in 'ASP General' started by please-answer-here, Jun 17, 2005.

  1. I want to store a bunch of textstrings (about 500) returned from a database
    query in a session array. I've googled all over the net, not to find any
    working method.

    Is there anybody who has the ultimative, definite working method as to how
    you transfer a "local" array to a session array and later transfer the
    session array to a "local" array.

    regards
    Henning
     
    please-answer-here, Jun 17, 2005
    #1
    1. Advertising

  2. "please-answer-here" <> wrote in message
    news:...
    >I want to store a bunch of textstrings (about 500) returned from a database
    >query in a session array. I've googled all over the net, not to find any
    >working method.
    >
    > Is there anybody who has the ultimative, definite working method as to how
    > you transfer a "local" array to a session array and later transfer the
    > session array to a "local" array.


    Simply assign it.

    Dim MyArray(500, 10)
    Session("MyArray") = MyArray

    The only caveat is that you must assign it from the session to a local
    variable before attempting to reference any of it's elements

    Dim MyArray, ele
    MyArray = Session("MyArray")
    ele = MyArray(1, 1)

    You cannot reference elements in the session object directly:

    Dim ele
    ele = Session("MyArray")(1, 1) ' does NOT work


    -Mark


    > regards
    > Henning
    >
     
    Mark J. McGinty, Jun 17, 2005
    #2
    1. Advertising

  3. Mark J. McGinty wrote:
    > "please-answer-here" <> wrote in message
    > news:...
    >> I want to store a bunch of textstrings (about 500) returned from a
    >> database query in a session array. I've googled all over the net,
    >> not to find any working method.
    >>
    >> Is there anybody who has the ultimative, definite working method as
    >> to how you transfer a "local" array to a session array and later
    >> transfer the session array to a "local" array.

    >
    > Simply assign it.
    >
    > Dim MyArray(500, 10)
    > Session("MyArray") = MyArray
    >
    > The only caveat is that you must assign it from the session to a local
    > variable before attempting to reference any of it's elements
    >
    > Dim MyArray, ele
    > MyArray = Session("MyArray")
    > ele = MyArray(1, 1)
    >
    > You cannot reference elements in the session object directly:
    >
    > Dim ele
    > ele = Session("MyArray")(1, 1) ' does NOT work


    Yes that was exactly what I found out, but in my case it didn't work (got
    all sorts of errormessages type mismatch / index out of range) Will take a
    closer look at my own code

    thanks for the assistance !
    >
    >
    > -Mark
    >
    >
    >> regards
    >> Henning
     
    please-answer-here, Jun 17, 2005
    #3
  4. Also use the following functions since variables are Empty by default

    If IsEmpty(myvar) Then....

    or
    If IsArray(myvar) Then
    Redim blah(20)
    Session("myvar") = blah
    End If

    --
    compatible web farm Session replacement for Asp and Asp.Net
    http://www.nieropwebconsult.nl/asp_session_manager.htm

    "please-answer-here" <> wrote in message
    news:42b28ec8$0$67263$...
    > Mark J. McGinty wrote:
    >> "please-answer-here" <> wrote in message
    >> news:...
    >>> I want to store a bunch of textstrings (about 500) returned from a
    >>> database query in a session array. I've googled all over the net,
    >>> not to find any working method.
    >>>
    >>> Is there anybody who has the ultimative, definite working method as
    >>> to how you transfer a "local" array to a session array and later
    >>> transfer the session array to a "local" array.

    >>
    >> Simply assign it.
    >>
    >> Dim MyArray(500, 10)
    >> Session("MyArray") = MyArray
    >>
    >> The only caveat is that you must assign it from the session to a local
    >> variable before attempting to reference any of it's elements
    >>
    >> Dim MyArray, ele
    >> MyArray = Session("MyArray")
    >> ele = MyArray(1, 1)
    >>
    >> You cannot reference elements in the session object directly:
    >>
    >> Dim ele
    >> ele = Session("MyArray")(1, 1) ' does NOT work

    >
    > Yes that was exactly what I found out, but in my case it didn't work (got
    > all sorts of errormessages type mismatch / index out of range) Will take a
    > closer look at my own code
    >
    > thanks for the assistance !
    >>
    >>
    >> -Mark
    >>
    >>
    >>> regards
    >>> Henning

    >
    >
     
    Egbert Nierop \(MVP for IIS\), Jun 18, 2005
    #4
  5. please-answer-here

    Bullschmidt Guest

    Bullschmidt, Jun 30, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob

    Global Session Variables and Session State

    Earl Teigrob, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,320
    Alvin Bruney
    Dec 17, 2003
  2. Replies:
    1
    Views:
    964
  3. Replies:
    9
    Views:
    1,006
  4. Philipp
    Replies:
    21
    Views:
    1,181
    Philipp
    Jan 20, 2009
  5. sjsean

    Session variables and arrays

    sjsean, Jun 28, 2007, in forum: Javascript
    Replies:
    3
    Views:
    181
    Hal Rosser
    Jun 29, 2007
Loading...

Share This Page