SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast cjam4's Avatar
    Join Date
    Jul 2001
    Location
    NJ
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    database connection method

    what is more efficient, opening the database once in the beginning of the page then closing it at the end of the page, or opening the db connection each time you need it.

    for example:

    i have a page that executes 50 queries. is it better to open the db, execute the queries, then close it, or to open and close the db 50 times?

    thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the quicker you can open and close it the better....if u need to do multiple quieries and need some info all the way through ur page, wack the info into an array with rs.getrows()

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Open the database connection ONCE. Open and close the recordsets EACH and everytime. Use getrows when you can to speed up the process significantly....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  4. #4
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://msdn.microsoft.com/library/de...ml/asptips.asp
    Tip 8: Acquire Resources Late, Release Early


Bookmarks

Posting Permissions

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