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.
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.
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
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.
so never mind the darknes, we still can find the way. Cause nothin' last forever, even cold November rain.(Rose)
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:
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.