Global.asa does not fire after reboot until re-saved.

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
 
B

Bob Barrows [MVP]

David said:
Hi Guys

Sub Application_OnStart
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

1. You don't seem to be doing anything with this error. At the leatst, you
should be logging it somewhere so you can see if your problem is caused by
an inability to connect to sql.

2. Have you tried taking the code out of the sub and putting it directly
into onstart? I know it should not be necessary, but doing so migh yield a
clue.
 
D

David Morgan

Bob Barrows said:
1. You don't seem to be doing anything with this error. At the leatst, you
should be logging it somewhere so you can see if your problem is caused by
an inability to connect to sql.

2. Have you tried taking the code out of the sub and putting it directly
into onstart? I know it should not be necessary, but doing so migh yield
a clue.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Hi Bob

Thanks for your reply.

1. Err.Raise in the Global.asa will halt the app. I have no need to log as
I will have 1000 emails telling me the site is down, if I don't find out
myself.

2. As mentioned above, saving it having made no changes appears to have
fixed it.

Will keep you informed.
 

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

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top