Centrilized Data Connection

Discussion in 'ASP General' started by TNGgroup, Aug 10, 2004.

  1. TNGgroup

    TNGgroup Guest

    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
     
    TNGgroup, Aug 10, 2004
    #1
    1. Advertising

  2. TNGgroup

    Evertjan. Guest

    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)
     
    Evertjan., Aug 10, 2004
    #2
    1. Advertising

  3. TNGgroup

    TNGgroup Guest

    THX !!

    "Evertjan." <> wrote in message
    news:Xns95416D303431Eeejj99@194.109.133.29...
    > 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)
     
    TNGgroup, Aug 10, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mythran
    Replies:
    5
    Views:
    4,973
    Mythran
    Oct 5, 2005
  2. Dave Johnson

    Using Connection Class VS Connection Module

    Dave Johnson, Dec 9, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    647
    Dave Johnson
    Dec 11, 2005
  3. Linus Nikander
    Replies:
    5
    Views:
    550
  4. Replies:
    3
    Views:
    40,447
    Roedy Green
    Nov 16, 2005
  5. R
    Replies:
    1
    Views:
    580
Loading...

Share This Page