application object vs includes file

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default application object vs includes file


    Is it better to :
    - use an application object to store my database connection string or
    - use an include file on each asp page that needs to connect to the
    database?

    Example:

    Using the application object I could use the following in my global.asa
    file:

    <SCRIPT LANGUAGE=VBScript RUNAT=Server>
    SUB Application_OnStart
    Application("ConnString") = "PROVIDER=myprovider; DATA SOURCE=myserver;
    USER ID=myid; PASSWORD=mypass"
    Application("Server_Name") = "http://mydev/mysystemname/"
    END SUB

    SUB Application_OnEnd
    END SUB

    SUB Session_OnStart
    startPage = "login.asp"
    Session.Timeout = 15
    END SUB
    </SCRIPT>

    Then I just add:
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open Application("connstring")
    to each of the asp pages that need to connect to the database.


    Alternatively, when using an includes file (eg. dbConnect.inc) I would
    put the following in the .inc file:

    Dim connStr, conn
    connStr = "PROVIDER=myprovider; DATA SOURCE=myserver; USER ID=myid;
    PASSWORD=mypass"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Mode = 3
    conn.Open connStr

    And then include the dbConnect.inc file in each of my pages that need to
    connect to the database this way:

    <!-- #INCLUDE file = "dbConnect.inc" -->


    Which is the better method?
    Does one have a performance advantage over the other?


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Luis Guest

  2. Similar Questions and Discussions

    1. Not ALL file information with the Shell.Application object in ASP
      The code below works fine on several Windows (2003/XP) IIS servers and shows all available file information of the images folder below the currect...
    2. Php includes? An html file?
      Hi all, I'm working on table that has to be updated quarterly by a client using either Contribute or DW. The table rotates each week and I have...
    3. Application Object
      How easy is it for a hacker to access data stored in the Application Object in IIS server. I want to store a decrpyted connection string there rather...
    4. Problem occurs when included file includes anther file.
      The directory structure is as follows: / |-- demo.php |-- inc/ |-- inc1.php |-- inc2.php === file demo.php == <?php require 'inc/inc1.php';
    5. [PHP] Problem occurs when included file includes anther file.
      Thank you for your reply first. Yes I know I could set include_path either in the php.ini or at runtime.But it's a little bit dirty I think.What...
  3. #2

    Default Re: application object vs includes file

    On Fri, 13 Aug 2004 04:21:48 -0700, Luis <andyzaNOSPAM@webmail.co.za>
    wrote:
    >Is it better to :
    > - use an application object to store my database connection string or
    > - use an include file on each asp page that needs to connect to the
    >database?
    Absolutely.
    >Which is the better method?
    Depends on your individual site/application/needs
    >Does one have a performance advantage over the other?
    See answer to the above question.

    Google the groups for many discussions on this. There are pros and
    cons on both, and the only place it can be determined is on your
    specific system for your specific application in your specific
    environment.

    Jeff
    Jeff Cochran Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139