D
Doris Edwards
Hello,
I have several .mdb Access databases stored with on a web server (not my
own, but with a very professional hosting service). I have developped .asp
forms with FrontPage
The individual web applications are placed in /webroot/(name of web) of the
hosting server's web server.
The databases belonging to the individual applications are stored in
/webroot/data of the hosting server's web server. I have established a DSN
pointer in ODBC data sources to point to the databases. All this works fine
when there is one application and one database.
The global.asa is generated by FrontPage is placed into /webroot, and off we
go.
The problem comes when there are several databases. My question :
FrontPage generates a global.asa for each application (I know that there can
be only one per application). As global.asa needs to be at the webroot, how
does this then work ? I have modified global.asa to include the pointers to
DSN's. I am listing the modified global.asa file than here below. But maybe
this is not the right approach. I get errors when opening the forms
Would be most grateful for your help. Thanks. Doris
---------------------------------------
Contents of GLOBAL.ASA
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(4)
'--Project Data Connection
Application("Catalogue_ConnectionString") = "DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=URL=data/Catalogue.mdb"
FrontPage_UrlVars(0) = "Catalogue_ConnectionString"
Application("Catalogue_ConnectionTimeout") = 15
Application("Catalogue_CommandTimeout") = 30
Application("Catalogue_CursorLocation") = 3
Application("Catalogue_RuntimeUserName") = "rikkit"
Application("Catalogue_RuntimePassword") = "ehql+cfz"
'--Project Data Connection
Application("Losinger2_ConnectionString") = "DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=URL=data/Losinger.mdb"
FrontPage_UrlVars(1) = "Losinger2_ConnectionString"
Application("Losinger2_ConnectionTimeout") = 15
Application("Losinger2_CommandTimeout") = 30
Application("Losinger2_CursorLocation") = 3
Application("Losinger2_RuntimeUserName") = "rikkit"
Application("Losinger2_RuntimePassword") = "ehql+cfz"
'--Project Data Connection
Application("GHS2004_ConnectionString") = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=URL=data/GHS2004.mdb"
FrontPage_UrlVars(2) = "GHS2004_ConnectionString"
Application("GHS2004_ConnectionTimeout") = 15
Application("GHS2004_CommandTimeout") = 30
Application("GHS2004_CursorLocation") = 3
Application("GHS2004_RuntimeUserName") = "rikkit"
Application("GHS2004_RuntimePassword") = "ehql+cfz"
'--Project Data Connection
Application("CatalogueVessy_ConnectionString") = "DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=URL=data/CatalogueVessy.mdb"
FrontPage_UrlVars(0) = "CatalogueVessy_ConnectionString"
Application("CatalogueVessy_ConnectionTimeout") = 15
Application("CatalogueVessy_CommandTimeout") = 30
Application("CatalogueVessy_CursorLocation") = 3
Application("CatalogueVessy_RuntimeUserName") = "rikkit"
Application("CatalogueVessy_RuntimePassword") = "ehql+cfz"
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==
End Sub
Sub Session_OnStart
FrontPage_StartSession '==FrontPage Generated==
End Sub
Sub FrontPage_StartSession
On Error Resume Next
if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub
' discover the VRoot for the current page;
' walk back up VPath until we find global.asa
Vroot = Request.ServerVariables("PATH_INFO")
strG1 = "global.asa"
strG2 = "Global.asa"
iCount = 0
do while Len(Vroot) > 1
idx = InStrRev(Vroot, "/")
if idx > 0 then
Vroot = Left(Vroot,idx)
else
' error; assume root web
Vroot = "/"
end if
if FrontPage_FileExists(Server.MapPath(Vroot & strG1)) then exit do
if FrontPage_FileExists(Server.MapPath(Vroot & strG2)) then exit do
if Right(Vroot,1) = "/" then Vroot = Left(Vroot,Len(Vroot)-1)
iCount = iCount + 1
if iCount > 100 then
' error; assume root web
Vroot = "/"
exit do
end if
loop
' map all URL= attributes in _ConnectionString variables
Application.Lock
if Len(Application("FrontPage_VRoot")) = 0 then
Application("FrontPage_VRoot") = Vroot
UrlVarArray = Application("FrontPage_UrlVars")
for i = 0 to UBound(UrlVarArray)
if Len(UrlVarArray(i)) > 0 then FrontPage_MapUrl(UrlVarArray(i))
next
end if
Application.Unlock
End Sub
Sub FrontPage_MapUrl(AppVarName)
' convert URL attribute in conn string to absolute file location
strVal = Application(AppVarName)
strKey = "URL="
idxStart = InStr(strVal, strKey)
If idxStart = 0 Then Exit Sub
strBefore = Left(strVal, idxStart - 1)
idxStart = idxStart + Len(strKey)
idxEnd = InStr(idxStart, strVal, ";")
If idxEnd = 0 Then
strAfter = ""
strURL = Mid(strVal, idxStart)
Else
strAfter = ";" & Mid(strVal, idxEnd + 1)
strURL = Mid(strVal, idxStart, idxEnd - idxStart)
End If
strOut = strBefore & Server.MapPath(Application("FrontPage_VRoot") &
strURL) & strAfter
Application(AppVarName) = strOut
End Sub
Function FrontPage_FileExists(fspath)
On Error Resume Next
FrontPage_FileExists = False
set fs = CreateObject("Scripting.FileSystemObject")
Err.Clear
set istream = fs.OpenTextFile(fspath)
if Err.Number = 0 then
FrontPage_FileExists = True
istream.Close
end if
set istream = Nothing
set fs = Nothing
End Function
</SCRIPT>
I have several .mdb Access databases stored with on a web server (not my
own, but with a very professional hosting service). I have developped .asp
forms with FrontPage
The individual web applications are placed in /webroot/(name of web) of the
hosting server's web server.
The databases belonging to the individual applications are stored in
/webroot/data of the hosting server's web server. I have established a DSN
pointer in ODBC data sources to point to the databases. All this works fine
when there is one application and one database.
The global.asa is generated by FrontPage is placed into /webroot, and off we
go.
The problem comes when there are several databases. My question :
FrontPage generates a global.asa for each application (I know that there can
be only one per application). As global.asa needs to be at the webroot, how
does this then work ? I have modified global.asa to include the pointers to
DSN's. I am listing the modified global.asa file than here below. But maybe
this is not the right approach. I get errors when opening the forms
Would be most grateful for your help. Thanks. Doris
---------------------------------------
Contents of GLOBAL.ASA
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(4)
'--Project Data Connection
Application("Catalogue_ConnectionString") = "DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=URL=data/Catalogue.mdb"
FrontPage_UrlVars(0) = "Catalogue_ConnectionString"
Application("Catalogue_ConnectionTimeout") = 15
Application("Catalogue_CommandTimeout") = 30
Application("Catalogue_CursorLocation") = 3
Application("Catalogue_RuntimeUserName") = "rikkit"
Application("Catalogue_RuntimePassword") = "ehql+cfz"
'--Project Data Connection
Application("Losinger2_ConnectionString") = "DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=URL=data/Losinger.mdb"
FrontPage_UrlVars(1) = "Losinger2_ConnectionString"
Application("Losinger2_ConnectionTimeout") = 15
Application("Losinger2_CommandTimeout") = 30
Application("Losinger2_CursorLocation") = 3
Application("Losinger2_RuntimeUserName") = "rikkit"
Application("Losinger2_RuntimePassword") = "ehql+cfz"
'--Project Data Connection
Application("GHS2004_ConnectionString") = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=URL=data/GHS2004.mdb"
FrontPage_UrlVars(2) = "GHS2004_ConnectionString"
Application("GHS2004_ConnectionTimeout") = 15
Application("GHS2004_CommandTimeout") = 30
Application("GHS2004_CursorLocation") = 3
Application("GHS2004_RuntimeUserName") = "rikkit"
Application("GHS2004_RuntimePassword") = "ehql+cfz"
'--Project Data Connection
Application("CatalogueVessy_ConnectionString") = "DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=URL=data/CatalogueVessy.mdb"
FrontPage_UrlVars(0) = "CatalogueVessy_ConnectionString"
Application("CatalogueVessy_ConnectionTimeout") = 15
Application("CatalogueVessy_CommandTimeout") = 30
Application("CatalogueVessy_CursorLocation") = 3
Application("CatalogueVessy_RuntimeUserName") = "rikkit"
Application("CatalogueVessy_RuntimePassword") = "ehql+cfz"
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==
End Sub
Sub Session_OnStart
FrontPage_StartSession '==FrontPage Generated==
End Sub
Sub FrontPage_StartSession
On Error Resume Next
if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub
' discover the VRoot for the current page;
' walk back up VPath until we find global.asa
Vroot = Request.ServerVariables("PATH_INFO")
strG1 = "global.asa"
strG2 = "Global.asa"
iCount = 0
do while Len(Vroot) > 1
idx = InStrRev(Vroot, "/")
if idx > 0 then
Vroot = Left(Vroot,idx)
else
' error; assume root web
Vroot = "/"
end if
if FrontPage_FileExists(Server.MapPath(Vroot & strG1)) then exit do
if FrontPage_FileExists(Server.MapPath(Vroot & strG2)) then exit do
if Right(Vroot,1) = "/" then Vroot = Left(Vroot,Len(Vroot)-1)
iCount = iCount + 1
if iCount > 100 then
' error; assume root web
Vroot = "/"
exit do
end if
loop
' map all URL= attributes in _ConnectionString variables
Application.Lock
if Len(Application("FrontPage_VRoot")) = 0 then
Application("FrontPage_VRoot") = Vroot
UrlVarArray = Application("FrontPage_UrlVars")
for i = 0 to UBound(UrlVarArray)
if Len(UrlVarArray(i)) > 0 then FrontPage_MapUrl(UrlVarArray(i))
next
end if
Application.Unlock
End Sub
Sub FrontPage_MapUrl(AppVarName)
' convert URL attribute in conn string to absolute file location
strVal = Application(AppVarName)
strKey = "URL="
idxStart = InStr(strVal, strKey)
If idxStart = 0 Then Exit Sub
strBefore = Left(strVal, idxStart - 1)
idxStart = idxStart + Len(strKey)
idxEnd = InStr(idxStart, strVal, ";")
If idxEnd = 0 Then
strAfter = ""
strURL = Mid(strVal, idxStart)
Else
strAfter = ";" & Mid(strVal, idxEnd + 1)
strURL = Mid(strVal, idxStart, idxEnd - idxStart)
End If
strOut = strBefore & Server.MapPath(Application("FrontPage_VRoot") &
strURL) & strAfter
Application(AppVarName) = strOut
End Sub
Function FrontPage_FileExists(fspath)
On Error Resume Next
FrontPage_FileExists = False
set fs = CreateObject("Scripting.FileSystemObject")
Err.Clear
set istream = fs.OpenTextFile(fspath)
if Err.Number = 0 then
FrontPage_FileExists = True
istream.Close
end if
set istream = Nothing
set fs = Nothing
End Function
</SCRIPT>