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. Database & SysAdmin
  3. Database
  4. Release data source

Release data source

Scheduled Pinned Locked Moved Database
questioncsharpasp-netdatabaseannouncement
3 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.
  • R Offline
    R Offline
    rico cheah
    wrote on last edited by
    #1

    I'm new to ASP.NET. Can anyone provide answer for my question below? 1. I have a database connection in Page 1; then after some process, it redirect to Page 2. Now my question is, if we don't close the connection (eg: MyDBConn.Close), after redirect to Page 2, will the resourse still grab in Page 1?

    C 1 Reply Last reply
    0
    • R rico cheah

      I'm new to ASP.NET. Can anyone provide answer for my question below? 1. I have a database connection in Page 1; then after some process, it redirect to Page 2. Now my question is, if we don't close the connection (eg: MyDBConn.Close), after redirect to Page 2, will the resourse still grab in Page 1?

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      You should always close the connection after working with the database. The best practice model for ADO.NET is aquire-query-release. You should always close a connection to the database as soon as your query is complete. Also, in ASP.NET the application is stateless. That means that when you request a page it creates a page, populates the page, streams the page to the browser, then deletes all resources used by the page. NOTE: If a connection to a database is not closed and it goes out of scope so that the garbage collector has to deal with it you will find that the connection stays open until such time as the garbage collector cleans up your mess. That might never happen because your application may break due to lack of connections before the garbage collector gets to it.


      *** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

      R 1 Reply Last reply
      0
      • C Colin Angus Mackay

        You should always close the connection after working with the database. The best practice model for ADO.NET is aquire-query-release. You should always close a connection to the database as soon as your query is complete. Also, in ASP.NET the application is stateless. That means that when you request a page it creates a page, populates the page, streams the page to the browser, then deletes all resources used by the page. NOTE: If a connection to a database is not closed and it goes out of scope so that the garbage collector has to deal with it you will find that the connection stays open until such time as the garbage collector cleans up your mess. That might never happen because your application may break due to lack of connections before the garbage collector gets to it.


        *** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

        R Offline
        R Offline
        rico cheah
        wrote on last edited by
        #3

        Thank you for the advice. I'm very much appreciated.

        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