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

connection files 1

Status
Not open for further replies.

Jamfool

IS-IT--Management
Apr 10, 2003
484
GB
I have a asp page that uses the following connection stored in a file called connection.asp.
e.g i use <!--#include file="connection.asp"--> at the top of my main page and use below stored in connection.asp

<%
set cnn = server.createobject("ADODB.Connection")
cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=<SERVER>;UID=<USER>;PWD=<PASS>;DATABASE=<DB>"
%>

However I would like the page to use multiple connections, in multiple connection files.

e.g connection1.asp, connection2.asp etc


how do i go about this so i can dynamically select which connection file i would like to use.

thanks
 
You mean you are changing which database you connect to based on some other criteria?

How do you determine which connection is appropriate?
I think something like this should work (untested).
This is looking at a posted form field value to determine which file to load. You could just as easily do it with the querystring, session variables, etc.

Code:
<%
  If Request.Form("WhichDB") = "MyDB1" Then
    %> <!--#include file="connection.asp"--> <%
  End If
  If Request.Form("WhichDB") = "MyDB2" Then
    %> <!--#include file="connection2.asp"--> <%
  End If
%>

Paranoid?  ME??   WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top