Results 1 to 3 of 3

Thread: ending application

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    ending application

    If a user clicks the X to close my web page, I want to destroy a database connection. How do I capture that event?

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Why do you have the database connection open for so long? If you need some things from the database to render on a page, do it in the page load event and get the data. Then close the connection when you are done getting the data. Then on post backs you can reopen the connection if you need to.

    You are not going to know when the user exits the browser, the only thing you can really do is store the connection in the session object, but that won't go away until after a certain amount of time has passed where the user no longer is accessing the server.

  3. #3
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    Not to mention that .Net will probably have closed it anyway. I always access data in asp.net like the following:-

    try
    conn.open
    dr = cmd.executereader
    'whatever else
    finally
    conn.close
    dr.close
    end try

    This will not raise an error if the objects are already closed like it might have done in asp.
    Also I'm using a datareader and yes in asp.net thats all I ever use. Why people have jumped at datasets and the dataadapter for webpages I'll never know.

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