TNGgroup wrote on 10 aug 2004 in
microsoft.public.inetserver.asp.general:
I have several ASP pages, and some of them are using the same access
Database and table.
Can I put the connection string somewhere centralized, so I can link
to it ?
<!-- #include virtual = "/dbLib/myDbConnectionString.asp"-->
It is also a nice possibility to put your login check in the same file:
=== myDbConnectionString.asp:
<%
Response.Expires = 0 ' or whatever
if session("user")="" then redirect "logon.asp"
if Application("Local") = "yes!" then ' [set by local global.asa]
set CONNECT = server.CreateObject("ADODB.Connection")
CONNECT.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("./myDB.mdb") & ";"
else
set CONNECT = server.CreateObject("ADODB.Connection")
CONNECT.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("/cgi-bin/myDB.mdb") & ";"
end if
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)