473,385 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Nov 9 '07 #1
2 2333
David Morgan wrote:
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.
--
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"
Nov 9 '07 #2

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
David Morgan wrote:
>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.
--
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.
Nov 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ted Dawson | last post by:
Last week I was storing my variables in a database and retrieving them on every page of my application, but this week I want to retrieve them only once and store them in an application variable....
4
by: Bill | last post by:
So when *does* Session_OnEnd fire in my Global.asa file? Does it fire when they click a link to leave the site? Does it fire when the session times out?
4
by: Max | last post by:
I've noticed some procedures don't run in the global.asax when you'd expect them to. I've rebuilt and set break points, but Application_Start just isn't firing today. Is there some configuration...
4
by: jzink | last post by:
I need to update a sql table with the last date/time that a user logged into my web site. The site is protected via integrated authentication. I can put code in the global.asax file to update...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
37
by: Joshua Ruppert | last post by:
When I'm using FastCGI do I need to code differently than I do when using regular CGI? Because the PHP.exe processes don't go away do global variables stick around from page request to page...
8
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
12
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they...
1
by: Nikolai | last post by:
What is the DOS file I need to edit to fire up executables? I know this is a really basic question, but I cannot figure it out; I even googled it, but no dice. I use old Word Perfect 5.1 for Medical...
1
by: daonho | last post by:
Hi Everyone, I have encountered this problem that I am not able to figure out. Please drop me some lines if you have any idea how to solve this issue. I have a global.asax file in my web site. It...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.