469,323 Members | 1,611 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Problem with global.asa & Session_End

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
Jul 19 '05 #1
7 5162
"PiGei" <ja***************@hotmail.com> wrote in message
news:eP****************@TK2MSFTNGP09.phx.gbl...
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/windowsserv...y/centers/iis/

Jul 19 '05 #2
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:bv**********@kcweb01.netnews.att.com...
"PiGei" <ja***************@hotmail.com> wrote in message
news:eP****************@TK2MSFTNGP09.phx.gbl... See #2
http://www.aspfaq.com/show.asp?id=2078

Tom Kaminski IIS MVP

Jul 19 '05 #3
"PiGei" <ja***************@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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
Jul 19 '05 #4

"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in
message news:10*************@corp.supernews.com...
"PiGei" <ja***************@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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
Jul 19 '05 #5
"PiGei" <ja***************@hotmail.com> wrote in message
news:OL*************@TK2MSFTNGP12.phx.gbl...

"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in
message news:10*************@corp.supernews.com...
"PiGei" <ja***************@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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

The only thing I can think of to try would be to make your code look as much
like the example as possible. First, I would try changing the execute to
look more like the example:

conn.execute sql, , 129

If that doesn't work, I don't know what else to suggest.

Good luck,
Peter

Jul 19 '05 #6
PiGei wrote:
"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in
message news:10*************@corp.supernews.com...
"PiGei" <ja***************@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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.
Jul 19 '05 #7

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:u5**************@tk2msftngp13.phx.gbl...

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
Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by JoRo | last post: by
1 post views Thread by Nathan Alden | last post: by
2 posts views Thread by James Hunter Ross | last post: by
2 posts views Thread by Amit | last post: by
12 posts views Thread by =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.