www.webdeveloper.com
Results 1 to 3 of 3

Thread: Global.asa

  1. #1
    Join Date
    Feb 2005
    Location
    Calgary
    Posts
    45

    Global.asa

    Hello all,

    Can you declare your database connection in your global.asa file rather than your asp file? I think you can.. but what would the benefits of doing it that way be?

    I've heard it's wrong to do your database connection(s) in your asp pages.. even if you're using include files to do this..?

    Help.

    Thanks
    Last edited by geekazoid; 03-01-2005 at 03:29 PM.

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    I haven't heard any such thing. I declare my connection string in my global.asa but I actually create the connection in an include file. The only reason I can think of that someone might say not to create the connection in each page (or in an include file) is because of the time to repeatedly connect and disconnect each time a page is requested. I have not found this to be a problem for the sites I have worked on -- but, then again, perhaps a high-volume site would need greater advantages.

  3. #3
    Join Date
    Feb 2003
    Posts
    2,745
    you should create an include file for your connection strings. use UDLs if at all possible for the actual connection parameters, then define constants in the include file that point to the UDL. This enhances security and allows you to change the connection string should u ever need to, in one place -- the UDL.

    open the database connection just b4 you need it and close it immediately after. at worst, open it at the start of the page, and close it at the end. never open it just because. database conections are the *most* precious resource in your system. don't waste them (and add overhead) by unnecessarily creating them, or by leaving then open longer than needed.

    The only reason I can think of that someone might say not to create the connection in each page (or in an include file) is because of the time to repeatedly connect and disconnect each time a page is requested
    quite the opposite, close 'em right away.

    of course, the best way is to create the actual connection in a DLL and instantiate a COM object, but for a pure asp answer...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles