Sub Session_OnEnd

Discussion in 'ASP General' started by cab, Jun 8, 2004.

  1. cab

    cab Guest

    i have the following code in the "Sub Session_OnEnd" routine that does not
    seem to run.....

    Sub Session_OnEnd

    strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User
    ID=xxxxxx;Pwd=xxxxxxx"

    Set objConnEnd = Server.CreateObject("ADODB.Connection")
    objConnEnd.Open strConnect

    strDelete = "DELETE formdata WHERE formMyCpsID = " & Session.SessionID
    objConnEnd.Execute

    strDelete objConnEnd.Close
    Set objConnEnd = Nothing

    End Sub

    ....can I access the Session.SessionID at this stage or has it already been
    killed?

    cheers,
    cab.
     
    cab, Jun 8, 2004
    #1
    1. Advertisements

  2. cab

    Evertjan. Guest

    cab wrote on 08 jun 2004 in microsoft.public.inetserver.asp.general:

    > i have the following code in the "Sub Session_OnEnd" routine that does
    > not seem to run.....
    >
    > Sub Session_OnEnd
    >
    > strConnect = "Driver={SQL Server};Server=SERVER;Database=database;
    > User
    > ID=xxxxxx;Pwd=xxxxxxx"
    >
    > Set objConnEnd = Server.CreateObject("ADODB.Connection")
    > objConnEnd.Open strConnect
    >
    > strDelete = "DELETE formdata WHERE formMyCpsID = " &
    > Session.SessionID objConnEnd.Execute
    >
    > strDelete objConnEnd.Close
    > Set objConnEnd = Nothing
    >
    > End Sub
    >
    > ...can I access the Session.SessionID at this stage or has it already
    > been killed?


    I don't know, but you could test this by global.asa:

    Sub Session_OnEnd
    application("testing") = Session.SessionID & "-!-"
    End Sub

    ===============
    In an asp-page test this with:

    if application("testing") = "" then
    respons.write "No session ended yet. Please try later."
    elseif application("testing") = "-!-" then
    respons.write "Session.SessionID not available in Session_OnEnd"
    else
    respons.write "Yes, Session.SessionID is available in Session_OnEnd"
    end if

    ================
    not tested ;-}


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 8, 2004
    #2
    1. Advertisements

  3. You can't rely on this to fire anyway.

    http://www.aspfaq.com/2078
    http://www.aspfaq.com/2491

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "cab" <> wrote in message
    news:40c55fdb$...
    > i have the following code in the "Sub Session_OnEnd" routine that does not
    > seem to run.....
    >
    > Sub Session_OnEnd
    >
    > strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User
    > ID=xxxxxx;Pwd=xxxxxxx"
    >
    > Set objConnEnd = Server.CreateObject("ADODB.Connection")
    > objConnEnd.Open strConnect
    >
    > strDelete = "DELETE formdata WHERE formMyCpsID = " & Session.SessionID
    > objConnEnd.Execute
    >
    > strDelete objConnEnd.Close
    > Set objConnEnd = Nothing
    >
    > End Sub
    >
    > ...can I access the Session.SessionID at this stage or has it already been
    > killed?
    >
    > cheers,
    > cab.
    >
    >
     
    Aaron [SQL Server MVP], Jun 8, 2004
    #3
  4. cab

    cab Guest

    it thought this might have been the case.
    i was testing my code below replacing the Session.SessionID with an actual
    value in the database.
    sometimes the database entry was deleted, but more often it was not.
    thanks.


    "Aaron [SQL Server MVP]" <> wrote in message
    news:u#...
    > You can't rely on this to fire anyway.
    >
    > http://www.aspfaq.com/2078
    > http://www.aspfaq.com/2491
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "cab" <> wrote in message
    > news:40c55fdb$...
    > > i have the following code in the "Sub Session_OnEnd" routine that does

    not
    > > seem to run.....
    > >
    > > Sub Session_OnEnd
    > >
    > > strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User
    > > ID=xxxxxx;Pwd=xxxxxxx"
    > >
    > > Set objConnEnd = Server.CreateObject("ADODB.Connection")
    > > objConnEnd.Open strConnect
    > >
    > > strDelete = "DELETE formdata WHERE formMyCpsID = " & Session.SessionID
    > > objConnEnd.Execute
    > >
    > > strDelete objConnEnd.Close
    > > Set objConnEnd = Nothing
    > >
    > > End Sub
    > >
    > > ...can I access the Session.SessionID at this stage or has it already

    been
    > > killed?
    > >
    > > cheers,
    > > cab.
    > >
    > >

    >
    >
     
    cab, Jun 9, 2004
    #4
    1. Advertisements

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. THY
    Replies:
    1
    Views:
    537
    Steve C. Orr, MCSD
    Aug 19, 2003
  2. Kathy Burke
    Replies:
    3
    Views:
    604
    Kathy Burke
    Nov 24, 2003
  3. Tee
    Replies:
    2
    Views:
    1,037
  4. loga123
    Replies:
    2
    Views:
    435
    loga123
    May 20, 2006
  5. Frank Wallingford

    Sub-sub-expression evaluation order

    Frank Wallingford, Dec 9, 2004, in forum: C Programming
    Replies:
    4
    Views:
    465
    Chris Torek
    Dec 10, 2004
  6. Ben
    Replies:
    2
    Views:
    1,257
  7. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    3,109
    Lawrence D'Oliveiro
    May 20, 2011
  8. wpy

    how to create sub control within sub control?

    wpy, Apr 7, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    251
    Stefan
    Apr 8, 2004
Loading...