Database update from global.asa

Results 1 to 2 of 2

Thread: Database update from global.asa

  1. #1
    Join Date
    Dec 1969

    Default Database update from global.asa

    I am having the hardest time getting the Session_OnEnd to update a database when the user&#039;s session ends. I know there is a lot of talk about the unreliability of Session_OnEnd executing. However, I have placed a unique number in a application variable that gets updated only by the Session_OnEnd. This tells me that the subroutine did execute. So why doesn&#039;t the database get updated? I have copied some of my code from other posts to this board that I believe has worked for others.<BR><BR>Here is my global.asa file. Prior to each test of this code, I edit this file and change the value of Application("DebugVariable") to a new number. So the only way this application var would get changed is if this code had been triggered.<BR><BR>&#060;script language="VBScript" runat="server"&#062;<BR><BR>Dim objConn, objRS, strConnection<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR>strConne ction = "DSN=CCPSalesSupportSQL;"<BR>objConn.Open strConnection<BR><BR>Sub Application_OnStart<BR> Application("Visits") = 0<BR> Application("Active") = 0<BR> Application("LastRestart") = Cstr(date())<BR>End Sub<BR><BR>Sub Application_OnEnd<BR>objRS.close<BR>objConn.close< BR>set objRS = Nothing<BR>set objConn = Nothing<BR>End Sub<BR><BR>Sub Session_OnStart<BR> Session.Timeout = 15<BR> Session("Start") = Now<BR> Application.lock<BR> Application("Visits") = Application("Visits") + 1<BR> Application("Active") = Application("Active") + 1<BR> Application.unlock<BR>End Sub<BR><BR>Sub Session_OnEnd<BR> Application.lock<BR> Application("Active") = Application("Active") - 1<BR> Application("DebugVariable") = "9"<BR> Application.unlock<BR> "update dbo.SiteLog set ActiveSession = &#039;N&#039; where UniqueColumn=&#039;" & Session("SessionID") & "&#039;", objConn<BR> set objRS = Nothing<BR>End Sub<BR><BR>&#060;/script&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Database update from global.asa

    Dunno of this is gonna work but you could try:<BR><BR>objConn.execute "update dbo.SiteLog set ActiveSession = &#039;N&#039; where UniqueColumn=&#039;" & Session("SessionID") & "&#039;"<BR><BR>Have you tried to use an static value for the sessionID, like:<BR><BR>"update dbo.SiteLog set ActiveSession = &#039;N&#039; where UniqueColumn=&#039;12345&#039;" (make sure the value exists in sbo.SiteLog)<BR><BR>Also you could try to execute it in the QueryAnalyzer to see if it works. <BR><BR>Good Luck<BR><BR>Peter<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts