PDA

View Full Version : Global.asa loosing values on reboot


dougancil2009
05-19-2009, 02:29 AM
I am using a Windows 2000 server and whenever the server is rebooted, the virtual paths to my SQL database seems to get lost and I have to rebuild the connection again with FrontPage (not my choice of Webdev but my boss swears by it.) Can anyone give me an idea as to why this may be happening?

Thank you

Old Pedant
05-19-2009, 02:35 AM
How are you creating the "virtual paths" in the first place???

What is storing them into the Application variable...or whatever else it is you are using?

Show your code for Global.ASA, perhaps?

dougancil2009
05-19-2009, 04:00 PM
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(1)
'--Project Data Connection
Application("PatientPlus_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/PatientPlus.mdb"
FrontPage_UrlVars(0) = "PatientPlus_ConnectionString"
Application("PatientPlus_ConnectionTimeout") = 15
Application("PatientPlus_CommandTimeout") = 30
Application("PatientPlus_CursorLocation") = 3
Application("PatientPlus_RuntimeUserName") = ""
Application("PatientPlus_RuntimePassword") = ""
'--
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

sFile = "global.asa"
sRootPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
if Left(sRootPath,1) = "/" then sSep = "/" else sSep = "\"
if Right(sRootPath,1) <> sSep then sRootPath = sRootPath & sSep
sRootPath = sRootPath & sFile

' discover the VRoot for the current page;
' walk back up VPath until we match VRoot
Vroot = Request.ServerVariables("PATH_INFO")
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 Server.MapPath(Vroot & sFile) = sRootPath 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
</SCRIPT>
<head><title>Web Settings for Active Server Pages</title><html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:connectionstatus msdt:dt="string">PatientPlus=1</mso:connectionstatus>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>

In looking this over, maybe I was incorrect in my earlier statement about virtual paths but that was kind of where I was thinking. What happens when I reboot this server is that there are 2 web pages that receive a yellow box database error, we delete the global.asa page, recreate the connection to the database and the 2 pages work again. I'm stumped as to why this happens on a reboot and really no other time.

dougancil2009
05-19-2009, 04:24 PM
I had also said that I was connecting to a SQL database, and as you can tell thats a connection to an access database.

Old Pedant
05-19-2009, 09:02 PM
It has something to do with the really crappy code that Front Page is putting in there because the basic connection string uses a URL to start with:

"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/PatientPlus.mdb"

The code in there goes in and replaces the URL= with the actual path to the .mdb file.

That is, the actual connection string will end up being something like

"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\some\path\fpdb\PatientPlus.mdb"

Why it fails on reboot I dunno.

My personal advice would be to rewrite all this crap to get rid of the Front Page dependencies.

On top of everything else, the Access Driver is an old and pretty buggy piece of software and you should have long, long, long since moved to the JET OLEDB driver.

The problem with my advice is that I dunno what other junk in there is needed by the Front Page aspects of your pages.

I'd probably be sorely tempted to just leave alone all the junk that is in there and then add a *NEW* Application variable with the absolute path to the database and using the Jet driver and then go into all your pages and replace all usage of Application("PatientPlus_ConnectionString") with this new application variable. That is, fix the connection problem and pray that the rest of the FP stuff stays stable enough to last until ASP finally disappears in the next few years.