Results 1 to 11 of 11

Thread: Maintain Variable Values

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Maintain Variable Values

    I'm sure this is a stupid question, but I still need the answer.
    I want to be able to populate a DataSet the first time an aspx page loads and have that DataSet available for future loads.
    Declaring the DataSet as static won't work because, as I've mentioned in another thread, static makes the variable shared between all sessions, so each session will not have a unique copy of the DataSet.
    Any ideas?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Maintain Variable Values

    Store it in the Application object with a key reference to a Session ID. You could store it in the Session object much easier, but, if you do so then it will be serialized and sent back to the client on each request. So if its a big dataset that would be a pain in the ass.

    One could also store a static array of DataSets, and refer to each by Session ID index...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Maintain Variable Values

    How about Caching the dataset object?

  4. #4

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Maintain Variable Values

    Quote Originally Posted by plenderj
    You could store it in the Session object much easier, but, if you do so then it will be serialized and sent back to the client on each request. So if its a big dataset that would be a pain in the ass.
    Why would a DataSet be sent to the client?
    There is no need for it, or are all Session variables sent?
    If they are why?
    I thought Session variables stayed on the server and were associated with an active Session.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Maintain Variable Values

    Quote Originally Posted by GlenW
    Why would a DataSet be sent to the client?
    There is no need for it, or are all Session variables sent?
    If they are why?
    I thought Session variables stayed on the server and were associated with an active Session.
    If I'm not mistaken, the Session ID only is sent to the client, and sent back to the server to identify the session information associated with that current browser session.

    That all said, if the dataset you're storing in your session object is large, it's going to take quite a bit of server resources. Not good, especially if you're doing this for thousands of users!

    That's why I had suggested caching the object. Btw, I'm not even sure if this dataset you want stored will be accessible to all users or just to one user.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Maintain Variable Values

    You also mentioned that the dataset should be available for future loads. Sessions end after a certain timeout periiod.

  7. #7

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Maintain Variable Values

    Quote Originally Posted by mendhak
    If I'm not mistaken, the Session ID only is sent to the client, and sent back to the server to identify the session information associated with that current browser session.
    That's what I thought.

    Quote Originally Posted by mendhak
    That all said, if the dataset you're storing in your session object is large, it's going to take quite a bit of server resources. Not good, especially if you're doing this for thousands of users!
    The DataSets may be large but the application is for intranet use with a very limited number of users, so that should not be a problem.

  8. #8
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Maintain Variable Values

    Everything you insert into a Session object is serialised, Base64 encoded, and sent to the client in the VIEWSTRING. Take a look at the source code of html pages and you'll see sometimes it can get really really big.

    Personally I would assign a SessionID to people. Then store all object in the Application object or whatever and list by SessionID...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Maintain Variable Values

    Quote Originally Posted by plenderj
    Everything you insert into a Session object is serialised, Base64 encoded, and sent to the client in the VIEWSTRING.
    No it isn't.
    Session objects are held on the server.
    The _VIEWSTATE holds values for controls on the page that have their EnableViewState property set to true, the default, and any ViewState variables you create.

  10. #10
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Maintain Variable Values

    I have absolutely no idea why I wrote that
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  11. #11

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Maintain Variable Values

    Quote Originally Posted by plenderj
    I have absolutely no idea why I wrote that
    I've felt like that before, like when I said "Will you marry me?" and "'course I meant it".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width