Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How and Where to store the data

How and Where to store the data

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pentellcc
    wrote on last edited by
    #1

    I'm new in ASP.net. I plan to develope a project based on ASP.net with C#. But I faced problem where how to store the data in ASP.net 2.0. For example, I had a few table in database -SQL server. Once the user search some information in database, it returned a list of record with content so that user can view them. And I planned to use object oriented way - create few classes such as order, order detail and invoice. Once the database returned the data to asp, it inserts data into those classes (order, order detail or invoice) and those classes can contain more that one record such as order1, order2, order 3 etc. But the problem is where should i store those classes that with data ? Should i store it in session or application? It is because once the user click to other asp.net pages, the classes that with data will lost. right? Sorry that asking this silly question. Any help with examples is appreciated. Danny

    G 1 Reply Last reply
    0
    • P Pentellcc

      I'm new in ASP.net. I plan to develope a project based on ASP.net with C#. But I faced problem where how to store the data in ASP.net 2.0. For example, I had a few table in database -SQL server. Once the user search some information in database, it returned a list of record with content so that user can view them. And I planned to use object oriented way - create few classes such as order, order detail and invoice. Once the database returned the data to asp, it inserts data into those classes (order, order detail or invoice) and those classes can contain more that one record such as order1, order2, order 3 etc. But the problem is where should i store those classes that with data ? Should i store it in session or application? It is because once the user click to other asp.net pages, the classes that with data will lost. right? Sorry that asking this silly question. Any help with examples is appreciated. Danny

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The web is stateless in it's basic form. As soon as you want to keep state, it will cost you, usually memory resources. Objects are normally not persisted from page to page, so the standard way of doing it is not to do it. Usually you just fetch them from the database again. If you want to persist the object, you can put them in session variables. Be carful about storing large objects in sesson variables, though, as the session objects live for a very long time. Objects in a web application usually lives mere milliseconds, so objects persisted in memory for minutes will be using relatively much memory resources. --- b { font-weight: normal; }

      P 1 Reply Last reply
      0
      • G Guffa

        The web is stateless in it's basic form. As soon as you want to keep state, it will cost you, usually memory resources. Objects are normally not persisted from page to page, so the standard way of doing it is not to do it. Usually you just fetch them from the database again. If you want to persist the object, you can put them in session variables. Be carful about storing large objects in sesson variables, though, as the session objects live for a very long time. Objects in a web application usually lives mere milliseconds, so objects persisted in memory for minutes will be using relatively much memory resources. --- b { font-weight: normal; }

        P Offline
        P Offline
        Pentellcc
        wrote on last edited by
        #3

        Ya. I know there is expensive to keep it on memory. But make always make a connection to database to fetch the data also expensive. Besides, users needs to wait for the procedure connect to database and obtain the data always. If I want to keep the data from database, session is the only way that I can use? Is there any other way to keep those data cross page to page?

        G 1 Reply Last reply
        0
        • P Pentellcc

          Ya. I know there is expensive to keep it on memory. But make always make a connection to database to fetch the data also expensive. Besides, users needs to wait for the procedure connect to database and obtain the data always. If I want to keep the data from database, session is the only way that I can use? Is there any other way to keep those data cross page to page?

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Pentellcc wrote:

          But make always make a connection to database to fetch the data also expensive.

          It's not expensive in the same way. Memory is a resource that has an absolute limit, while database calls are only limited by the execution time. Allocating too much memory causes the server to stop, while too many queries only makes it go slower.

          Pentellcc wrote:

          If I want to keep the data from database, session is the only way that I can use? Is there any other way to keep those data cross page to page?

          Application variables, application cache, static variables... all those are shared by all users, though, so you need to separate the stored data using a unique key, and you need to use locking to make it thread safe. --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups