Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping a database connection available

Status
Not open for further replies.

Tve

Programmer
May 22, 2000
166
0
0
FR
Hi,

I started a tread about recordsets an I would like to thank link9 for his (quick) answer.

This is similar question:

Can I also put a connection object in a session, like for recordsets? I'm connecting to an Oracle database, and the connecting to the data source requires some time (not much, but time anyway.)

Are there disadvantages to doing this?

Thanks,

Thierry
 
There are MAJOR disadvantages to putting COM Objects in sessions. Charles Carroll has an excellent article on his site explaining this at:


As a rule, never place COM objects in Sessions or Applications collections.
cquick@geotg.com
Geographic Information System (GIS), ASP, some Oracle
 
Hi,

Yes, You can keep your connection state in session level.

Cheers,
Sri...
 
Yes you can do that but you should not.
you should open connection, get information, and close connection asap.

 
Can you explain why it's better to open connections and close them rather than keeping a connection variable open throughout the time the user is logged in and using an application?

I support an intranet application at a medical center, and the call center intake workers are accessing the database for retrieval, inserts, deletes and updates all throughout their eight-hour shifts. There's a lot of "overhead" in opening database connections on every page, and we're wondering if we can keep the number of connections being opened down to a minimum.

Thanks in advance for your feedback/advice.

Adele Miller
Application Engineer
 
you don't add any overhead, you actually reduce it.
The object is instatiated, used and destroyed faster than you can blink. Using a session variable causes the memorary use to be constant, and once a session ends by default the connection is lost. I work a lot in Oracle, and using one open connection, that connection manager has to control takes a ton more time than following good ASP coding and opening, using, closing, destroying.
 
Thanks glendsj for clarifying bushey's qn. I had that same question.

I'm currently running a huge ASP application with a SQL Server database. I've created 2 include files: dbConnection.asp and dbCleanup.asp. THe first file contains all the instantiation of connection and recordset objects, as well as the assignment of the connection string, etc. The 2nd file just sets all the objects to Nothing.

I'm including these two files at the Top and Bottom of every ASP page in my application.

Is this the recommended method (according to what glendsj just recommended)? Is it generating any unnecessary overhead?

Are there any other tips to recommend for improving the efficiency of the database connections in a large ASP application?

Thanks much for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top