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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Includes with DSN info?

Status
Not open for further replies.

adknbvi

Programmer
Apr 17, 2001
25
US
Hi,
I have a web application with many (JavaScript) ASP pages. Currently, the following lines are in every one:

var adoConnection = Server.CreateObject("ADODB.Connection");
adoConnection.Open("DSN=MY_DSN");

This connection string may have to change in the future - due to configuration changes in the production environment. I would really like to move these lines into an INCLUDE file and just reference them once.

Can anyone give me an idea of how I would do this? I have tried building a function with just these two lines in it, then calling that function, but it hasn't worked for me. It's like I can't successfully pass "adoConnection" back and forth from the function.

Thanks in advance!

 
I think I answered my own question. The first line has to stay in every file, but the second line (the one I anticipate changing in the future) can go into a one-line function. I pass adoConnection back and forth to/from the function and it seems to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top