D
David Morgan
Hi Guys
I have been working with ASP for many years but have _never_ come across
this. Sure, I've had the global.asa not execute because of application
misconfiguration, but check this out...
Server (W2K3 R2) reboots, website comes back up, but no application
variables loaded.
What makes it even more bizarre is that the variables that are set in
Application_OnStart _are_ loaded, like the connection string, but others
that are loaded by calling other subroutines are not. For example, below
the SITE_ID and NODE_ID and Connection String variables are set and are
accessible on other ASP pages, however anything that is set via the
InitAppVars subroutine are not set (see below).
Rebooting the server makes no difference. Saving the global.asa causes the
application to load _all_ the variables again properly. How wierd is that?
Could it be something to do with application locking?
Thanks in advance
David
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Const SITE_ID = 1
Const NODE_ID = 0
Server.ScriptTimeout = 300
Sub Application_OnStart
Application("Database_ConnectionString") =
"Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User
ID=sa;Initial Catalog=SiteControl;Data Source=192.168.0.100;Use Procedure
for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=X;Use
Encryption for Data=False;Tag with column collation when possible=False;User
Id=sa;PASSWORD=password;"
Application("SITE_ID") = SITE_ID: Application("NODE_ID") = NODE_ID
Application("Datashape_ConnectionString") = "Provider=MSDataShape.1;Data "
& Application("Database_ConnectionString")
InitAppVars
End Sub
Sub InitAppVars
Dim objConn, objRs
Set objConn = Server.CreateObject("ADODB.Connection")
On Error Resume Next
objConn.Open Application("Database_ConnectionString")
If Err Or objConn.State <> adStateOpen Then
Err.Raise Err.Number, Err.Source, "The Web Site's Database could not be
opened.<br>" & Err.Description
Exit Sub
End If
On Error Goto 0
Set objRs = Server.CreateObject("ADODB.RecordSet")
objRs.Open "tblAppVars", objConn, adOpenForwardOnly, adLockReadOnly,
adCmdTable
If Not objRs.EOF Then
With objRs
Do While Not .EOF
Select Case UCase(.Fields(3).Value)
Case "STR"
Application(.Fields(1).Value) = .Fields(4).Value
Case "LNG"
Application(.Fields(1).Value) = CLng(.Fields(4).Value)
Case "DBL"
Application(.Fields(1).Value) = CDbl(.Fields(4).Value)
Case "BOL"
Application(.Fields(1).Value) = CLng(.Fields(4).Value) <> 0
End Select
.MoveNext
Loop
End With
End If
objRs.Close
Set objRs = Nothing
objConn.Close
Set objConn = Nothing
End Sub
I have been working with ASP for many years but have _never_ come across
this. Sure, I've had the global.asa not execute because of application
misconfiguration, but check this out...
Server (W2K3 R2) reboots, website comes back up, but no application
variables loaded.
What makes it even more bizarre is that the variables that are set in
Application_OnStart _are_ loaded, like the connection string, but others
that are loaded by calling other subroutines are not. For example, below
the SITE_ID and NODE_ID and Connection String variables are set and are
accessible on other ASP pages, however anything that is set via the
InitAppVars subroutine are not set (see below).
Rebooting the server makes no difference. Saving the global.asa causes the
application to load _all_ the variables again properly. How wierd is that?
Could it be something to do with application locking?
Thanks in advance
David
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Const SITE_ID = 1
Const NODE_ID = 0
Server.ScriptTimeout = 300
Sub Application_OnStart
Application("Database_ConnectionString") =
"Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User
ID=sa;Initial Catalog=SiteControl;Data Source=192.168.0.100;Use Procedure
for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=X;Use
Encryption for Data=False;Tag with column collation when possible=False;User
Id=sa;PASSWORD=password;"
Application("SITE_ID") = SITE_ID: Application("NODE_ID") = NODE_ID
Application("Datashape_ConnectionString") = "Provider=MSDataShape.1;Data "
& Application("Database_ConnectionString")
InitAppVars
End Sub
Sub InitAppVars
Dim objConn, objRs
Set objConn = Server.CreateObject("ADODB.Connection")
On Error Resume Next
objConn.Open Application("Database_ConnectionString")
If Err Or objConn.State <> adStateOpen Then
Err.Raise Err.Number, Err.Source, "The Web Site's Database could not be
opened.<br>" & Err.Description
Exit Sub
End If
On Error Goto 0
Set objRs = Server.CreateObject("ADODB.RecordSet")
objRs.Open "tblAppVars", objConn, adOpenForwardOnly, adLockReadOnly,
adCmdTable
If Not objRs.EOF Then
With objRs
Do While Not .EOF
Select Case UCase(.Fields(3).Value)
Case "STR"
Application(.Fields(1).Value) = .Fields(4).Value
Case "LNG"
Application(.Fields(1).Value) = CLng(.Fields(4).Value)
Case "DBL"
Application(.Fields(1).Value) = CDbl(.Fields(4).Value)
Case "BOL"
Application(.Fields(1).Value) = CLng(.Fields(4).Value) <> 0
End Select
.MoveNext
Loop
End With
End If
objRs.Close
Set objRs = Nothing
objConn.Close
Set objConn = Nothing
End Sub