Centrilized Data Connection

T

TNGgroup

Hi,

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 ?

Thx in advance

TNGgroup
 
E

Evertjan.

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
%>
 
T

TNGgroup

THX !!

Evertjan. said:
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
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top