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

Discussion in 'ASP General' started by David Morgan, Nov 9, 2007.

  1. David Morgan

    David Morgan Guest

    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
     
    David Morgan, Nov 9, 2007
    #1
    1. Advertising

  2. 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"
     
    Bob Barrows [MVP], Nov 9, 2007
    #2
    1. Advertising

  3. David Morgan

    David Morgan Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:%...
    > 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.
     
    David Morgan, Nov 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    475
    Wayne
    Nov 11, 2003
  2. Shiva
    Replies:
    1
    Views:
    331
    Shiva
    Jul 28, 2004
  3. Iain
    Replies:
    7
    Views:
    2,242
  4. Ted Dawson

    re-fire global.asa ?

    Ted Dawson, Oct 10, 2004, in forum: ASP General
    Replies:
    3
    Views:
    119
    Ted Dawson
    Oct 11, 2004
  5. smay

    emails queued until reboot

    smay, Feb 14, 2006, in forum: ASP General
    Replies:
    0
    Views:
    111
Loading...

Share This Page