Problem with global.asa & Session_End

P

PiGei

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
 
T

Tom Kaminski [MVP]

PiGei said:
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
 
P

PiGei

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
 
P

PiGei

Peter Foti said:
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
 
B

Bob Barrows

PiGei said:
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
 
P

PiGei

Bob Barrows said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top