About database connection

Results 1 to 3 of 3

Thread: About database connection

  1. #1
    Join Date
    Dec 1969

    Default About database connection

    Is it feasible to open a connection in Application_Onstart event and then close it in Application_Onend OR Connection should be opened and closed in each and every page where needed.Which is better?

  2. #2
    Join Date
    Dec 1969

    Default RE: About database connection

    You could open and close your connection in a Global.asa file or in the page itself. Maybe you are confusing closing a connection in a session event rather than an application event??? The application_onend event would only close connections to your database when the server is shutdown...this would be very, very bad...don&#039t do that.

  3. #3
    Matt Jacyno Guest

    Default RE: About database connection

    Always open and close your ADO connections on each page (I&#039m assuming you&#039re using ADO, even though you don&#039t specifically say).<BR><BR>The ADODB.Connection object is Apartment-threaded, so it will cause performance problems if you use it at Session scope. Application scope is even worse.<BR><BR>Hopefully you&#039re using SQL Server, which supports connection pooling.<BR><BR>Opening and closing connections on every page might sound bad and inefficient, but it&#039s the way to go.<BR><BR>Oh, but wait - to answer your first question, yes it&#039s feasible. Just don&#039t do it. ;-)<BR><BR>Matt

Posting Permissions

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