SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multiple connections on one page?

    If you are going to be making multiple calls to the same database from a single page, should you connect/close, connect/close, connect/close....or just connect once at the beginning of the page and close at the end?

    Does that make sense?

  2. #2
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Connect once - I generally use a global function for it.
    Code:
    'placed in a global include
    Dim oConn, sConn
    
    Public Sub openDB()
     'set your connection string here
     sConn = "DSN=myDSN"
     Set oConn = CreateObject("ADODB.Connection")
     oConn.open sConn
    End Sub
    
    Public Sub closeDB()
     oConn.close
     Set oConn = Nothing
    End Sub
    
    'On any given asp page
    openDB()
    'one or more recordsets
    closeDB()
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,204
    Mentioned
    106 Post(s)
    Tagged
    1 Thread(s)
    I agree. One Connection to the database per page.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  4. #4
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks...!


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
  •