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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way for database Connection ??

Status
Not open for further replies.

vikramonline

Programmer
Oct 14, 2003
186
IN
We are creating a site which uses an Access Database in ASP.Right now what we are doing is that we are opening connection in every page.I doubt that there shd be some better way.

Please suggets.
 
use an include file to hold the connection data, then include that file when you need to access the database.
 
Thanx Simon,

But I guess including a file in every page will once again multiple connections one for each page.

I want to know whether we can create only one connection and use it everywhere(in every page)

 
I prefer to put all common functions and declarations into an included file and call them as needed, Opening and closing the connection each time should be the way to go, especially for Access.
I'm not sure what you mean by multiple connections, there should only be need for one Connection object and then create, open and close the Recordset objects as needed.



Chris.

Indifference will be the downfall of mankind, but who cares?
 
I believe he means multipl connections as the user browsers multiple pages.
It would be posible to have a connection that got held as a session variable or application variable that was an open conneciton (I think, not remembering to well) the problem here is that you are then tying up memory for the connection for the uarter second you use it while loading a page as well as the 5 minutes the uer is reading the page. If you do this on the session level than you will very soon max out your connections as multiple vistors have connections open for long periods. If you do it on the application level then you have one connection that many users are fighting over if they all hit refresh or a page link at the same time.

I have yet to have any efficiency issues with opening one connection per page thsan closing it after processing the page. This way you have a little overhead of creating and throwing away the object, but the connection is only live while the page is being processed.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Thanx All for ur valuable input and Sorry for the late reply
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top