Opening/Closing Connections

Results 1 to 2 of 2

Thread: Opening/Closing Connections

  1. #1
    Join Date
    Dec 1969

    Default Opening/Closing Connections

    Hello all,<BR><BR>For quite some time I have been using an include file to open my database connection(s) so I don&#039;t have to do this in each and every page. Rather than close the connection in each page, I check to see if the variable is an object and if it is, I close the connection and clear the variable. <BR><BR>This method has been working for about a year using Jet.. but lately, I have been running into problems with a site I have that is using MySQL.<BR><BR>Is this method a good idea, bad, stupid, or what? Would it be a little more efficient to open the connection when the session starts and close it when the session ends? From what I have read, it&#039;s not a good idea to store a connection object as a session variable?<BR><BR>Thanks!<BR><BR>--Tim

  2. #2
    Join Date
    Dec 1969

    Default Open and close as soon as possible

    Never leave connections open any longer than necessary. If you have a lot of database interaction in a page without a lot of HTML writes to the browser in between them, use the same connection across Subs/Functions.<BR><BR>Otherwise, you should be opening the connection and closing it after each database interaction.

Posting Permissions

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