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?
| SitePoint Sponsor |
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?





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()

I agree. One Connection to the database per page.
Thanks...!
Bookmarks