SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    May 2000
    Location
    temecula, ca, usa
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was told by our webmaster that I could set up a parameter in the default.asa file in my web root directory to connect to a database rather than using a DSN. Can any body tell me what the parameter is or where I can get specific information on this? I also need to understand all of the other parameters that can be used in this file.

    thanks.

    ------------------
    Annie

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Even though you're not using the Data Source Name (DSN) you're still connecting to the database. It's called DSN-less connections and are not only faster but quite popular.

    Instead of:
    objConn.Open "DSN=dsn_here"

    You'd put:
    objConn.Open "DRIVER=driver_name_for_your_db;DBQ=z:\path\to\db.mdb"

  3. #3
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you sure he said "default.asa" and not "global.asa"?? The global.asa file is what allows you to manipulate Application and Session variables or objects.

    DSN-Less connections are faster and more popular but they are also less secure. If your page crashes and the source is revealed somehow then the user where see where you store your database. This is a very remote possibility but could still happen.

    ------------------
    Wayne Luke - Sitepoint Moderator/Internet Media Developer
    Digital Magician Studios - Making Magic with Web Applications
    wluke@digitalmagician.com

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was assuming he meant global.asa.

    Personally I use DSN database connections just because they're safer and easier to code. Also the performance difference was a tiny, tiny amount, so it doesn't seem to matter that much. If each visitor has to wait .05 seconds longer, then let them

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Location
    Louisville, KY, US
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Forgive me if I am wrong. I am a newbie with ASP but I have read in a article that the Global.asa only is for inialization purposes and that you not shall use it for the creation of objects etc.
    I should make the connection in a seperate file and access this file with a <-#include file -> in the page which needs it.
    Hopes this helps.

    EMB

    ------------------
    so never mind the darknes, we still can find the way. Cause nothin' last forever, even cold November rain.(Rose)

  6. #6
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The global.asa is where you manage both the Application and Session objects. If you wanted to establish a database connection for each user as they entered your site then you would do it in the global.asa. Unfortunately this is very wasteful because if your default session is set to 20 minutes (normal default) and the user leaves after 30 seconds, that connection will sit around useless for 19 minutes and 30 seconds. Of course depending on the connection you open this could use a lot of system resources and memory and limit the number of session you can have.

    Now if you only access one database and want the connection string readily available you can put it in the Application object. So you would create a variable like:
    Application("MyConn") = "DSN=mydatabase"

    Then in the rest of your site you can access your database by stating:
    Open Application("MyConn")

    Of course there is other code as well. I keep my connection strings in a separate file called DBOperations.asp. It includes the connection strings I need and it has simple functions to open and close connections. This file has to be included in every ASP page I wish to use the database in though.

    There are many different ways to accomplish things in ASP. You have to find what is right for you.

    ------------------
    Wayne Luke - Sitepoint Moderator/Internet Media Developer
    Digital Magician Studios - Making Magic with Web Applications
    wluke@digitalmagician.com


Bookmarks

Posting Permissions

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