Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Properties Files in ASP

Status
Not open for further replies.

MWF

Programmer
May 20, 2009
1
US
I have a file called datasource.asp, with the following contents:
Code:
<%
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "ApplicationDataSource","db_table","db_password"
    Set Session("ApplicationDataSource_conn") = conn
%>
Since the application source code gets deployed to our dev, test, and prod environments, and each environment has a different password for the connection, I would like to read in the password from a properties file that is stored outside of the source code's root directory. This would isolate the environment-specific data and prevent anything from getting overwritten during the deployment process.

For example, if all of the .asp files are stored in the /project_x/app directory, I'd like to have the password stored in /project_x/properties/db_properties.properties (or db_properties.txt, etc.).

Can someone please point me to some documentation on properties files in ASP? I've searched and the closest I've come is this: which is just a how-to on using an include file rather than reading in specific data from a properties file.
 
Includes are useful. A common method of doing this is to have your asp files stored in [tt]/project_name/[/tt] and then have the includes stored in [tt]/project_name/inc/[/tt] with the file called [tt]connect.asp[/tt] / [tt]config.asp[/tt]... you get the idea.

Another thing to look up is the [tt]global.asa[/tt] file. This sits in your project root directory, and is available to all pages in that tree - without using #includes. It looks something like:

Code:
SUB Application_OnStart
  openConn
END SUB

SUB Application_OnEnd
  closeConn
END SUB

SUB openConn
  Set conn = Server.CreateObject("ADODB.Connection")
  conn.open "ApplicationDataSource","db_table","db_password"
  Set Session("ApplicationDataSource_conn") = conn
END SUB

SUB closeConn
  conn.close
END SUB

For more reading, use your favourite search engine and look for "ASP classic global.asa"

________________________________
Top 10 reasons to procrastinate:
1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top