Problem with global.asa & Session_End

Discussion in 'ASP General' started by PiGei, Feb 5, 2004.

  1. PiGei

    PiGei Guest

    Hello everybody.
    With the following code:

    =======
    Sub Session_OnEnd

    Application.Lock
    Application("online") = Application("online") - 1
    Application.UnLock

    ' set the flag active = 0
    Set dbConn = Server.CreateObject("adoDB.connection")
    dbConnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    Server.MapPath("\mydb.mdb")
    dbConn.Open dbConnstr
    SQLstr = "UPDATE tbl_sessionid SET active='0' WHERE sessionid ='" &
    Session("sID") & "'"
    dbConn.Execute(SQLstr)
    dbConn.Close

    End Sub
    =======

    the first 3 lines are executed when I force the session.abandon but the
    others, that set the active flag in an Access DB to 0 aren't.
    the same code works fine if I use it in a separate page.

    What's wrong with my global.asa?
    Thanks in advance

    PGei
    PiGei, Feb 5, 2004
    #1
    1. Advertising

  2. "PiGei" <> wrote in message
    news:ePNdak%...
    > Hello everybody.
    > With the following code:
    >
    > =======
    > Sub Session_OnEnd
    >
    > Application.Lock
    > Application("online") = Application("online") - 1
    > Application.UnLock
    >
    > ' set the flag active = 0
    > Set dbConn = Server.CreateObject("adoDB.connection")
    > dbConnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    > Server.MapPath("\mydb.mdb")


    See #2
    http://www.aspfaq.com/show.asp?id=2078

    --
    Tom Kaminski IIS MVP
    http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
    http://mvp.support.microsoft.com/
    http://www.microsoft.com/windowsserver2003/community/centers/iis/
    Tom Kaminski [MVP], Feb 5, 2004
    #2
    1. Advertising

  3. PiGei

    PiGei Guest

    I read it, I did all the modification but the code isn't fired anyway...
    No error message, seimply it doesn't work.

    If I put the first 3 lines below the include, then this code too doesn't
    work anymore.

    I don't know how to solve the problem...
    I read in this tip http://www.aspfaq.com/2491 that with SQL is possible
    to write in a db in the on_end section.

    I'm using Access but I can't fire the writing...

    Any suggestion?

    THX
    PGei

    "Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
    news:bvtkug$...
    > "PiGei" <> wrote in message
    > news:ePNdak%...


    > See #2
    > http://www.aspfaq.com/show.asp?id=2078
    >
    > Tom Kaminski IIS MVP
    PiGei, Feb 5, 2004
    #3
  4. PiGei

    PiGei Guest

    "Peter Foti" <> wrote in
    message news:...
    > "PiGei" <> wrote in message
    > news:u9pXmw$...
    > > I read it, I did all the modification but the code isn't fired

    anyway...
    >
    > Apparently you didn't read it closely enough:
    >
    > "Session_OnEnd does not support the request, response or server

    objects"
    >
    > You are attempting to use the server object, which is not supported.

    And
    > article 2491 does NOT use the server object. That is, it does

    CreateObject
    > instead of Server.CreateObject.
    >
    > Hope this helps.
    > Regards,
    > Peter Foti
    >


    I reposted the code... but it still doesn't work.
    The code under Application.UnLock seems not to be executed because the
    field active in the DB doesn't change to 1

    I'm desperated...

    Sub Session_OnEnd

    Application.Lock
    Application("collegati") = Application("collegati") - 1
    Application.UnLock

    '=======================================================================
    =======
    ' inizio codice per settaggio flag active a 1 in uscita
    '=======================================================================
    =======
    Set dbConn = CreateObject("adoDB.connection")

    dbConnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\inetpub\wwwroot\my.mdb"

    dbConn.Open dbConnstr

    SQLstr = "UPDATE tbl_sessionid SET active='1' WHERE sessionid ='" &
    Session("sID") & "'"

    dbConn.Execute(SQLstr)

    dbConn.Close
    Set dbConn = Nothing
    '=======================================================================
    =======
    ' fine codice per settaggio flag active a 1 in uscita
    '=======================================================================
    =======

    End Sub
    PiGei, Feb 5, 2004
    #4
  5. PiGei

    Bob Barrows Guest

    PiGei wrote:
    > "Peter Foti" <> wrote in
    > message news:...
    >> "PiGei" <> wrote in message
    >> news:u9pXmw$...
    >>> I read it, I did all the modification but the code isn't fired

    > dbConnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=c:\inetpub\wwwroot\my.mdb"
    >
    > dbConn.Open dbConnstr


    In some cases, the OnEnd events run under the context of the
    IWAM_machinename account. Since you wish that account to update an Access
    database, that account needs to be granted NTFS Change permissions for the
    folder containing the database.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows, Feb 5, 2004
    #5
  6. PiGei

    PiGei Guest

    "Bob Barrows" <> wrote in message
    news:u5D$...
    >
    > In some cases, the OnEnd events run under the context of the
    > IWAM_machinename account. Since you wish that account to update an

    Access
    > database, that account needs to be granted NTFS Change permissions for

    the
    > folder containing the database.


    That's exactly the problem.
    Updating the permission all runs OK...

    Thanks a lot to everybody

    PGei
    PiGei, Feb 5, 2004
    #6
    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:
    456
    Wayne
    Nov 11, 2003
  2. =?Utf-8?B?QmVsYQ==?=

    Problem with Session_End in Global.asax

    =?Utf-8?B?QmVsYQ==?=, Apr 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,536
    coollzh
    Apr 13, 2004
  3. yuridia

    Problem loading ASP and global.asa in IIS 5.0

    yuridia, Oct 13, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    98
    yuridia
    Oct 13, 2004
  4. Tom Bates
    Replies:
    0
    Views:
    132
    Tom Bates
    Sep 8, 2003
  5. Savas Ates

    global asa problem..?

    Savas Ates, Jul 30, 2004, in forum: ASP General
    Replies:
    1
    Views:
    87
Loading...

Share This Page