Author |
Message |
Aaron Lace #1 / 13
|
 Why isn't this working?
I am trying to update a user's database information once his session has expired, but it is not working. (I want to update the record "online" to 0 to indicate that the user is not online anymore) Here is the code in the Global.asa file that I am using: Sub Session_OnEnd if session("nickname")<>"" and session("password")<>"" then Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/db/members_97.mdb")) Sql = "Select * From member_table Where nickname='"& session("nickname") & "' AND password = '"& session("password") & "'" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open Sql, Conn, 3, 3 sql = "Update member_table Set online='0'" sql = sql & "where nickname='" & session("nickname") & "'" set Rs = Conn.Execute(sql) end if End Sub Any help would be much appreciated, thank you! Aaron Lacey -- Aaron Lacey
|
Tue, 24 Dec 2002 03:00:00 GMT |
|
 |
Barry Dorran #2 / 13
|
 Why isn't this working?
Server.MapPath does not work in Session_OnEnd. Map it in the Session_OnStart, then store it in a Session Variable. Barry (Hardly a SQL question though, watch the cross posts please)
|
Tue, 24 Dec 2002 03:00:00 GMT |
|
 |
Graham Sha #3 / 13
|
 Why isn't this working?
Not certain, bur as the session has ended are the session variables still active? -- Graham Shaw MCP MCP+I MCSE Please reply to the newsgroup only, not by email.
I am trying to update a user's database information once his session has expired, but it is not working. (I want to update the record "online" to 0 to indicate that the user is not online anymore) Here is the code in the Global.asa file that I am using: Sub Session_OnEnd if session("nickname")<>"" and session("password")<>"" then Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/db/members_97.mdb")) Sql = "Select * From member_table Where nickname='"& session("nickname") & "' AND password = '"& session("password") & "'" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open Sql, Conn, 3, 3 sql = "Update member_table Set online='0'" sql = sql & "where nickname='" & session("nickname") & "'" set Rs = Conn.Execute(sql) end if End Sub Any help would be much appreciated, thank you! Aaron Lacey -- Aaron Lacey
|
Tue, 24 Dec 2002 03:00:00 GMT |
|
 |
Aaron Lace #4 / 13
|
 Why isn't this working?
Does anyone have any suggestions on an alternative to this? I just want to update a record in the database once the user has left the site or their session has ended. Than you very much, Aaron Lacey -- Aaron Lacey Web Development Director
www.2bros.com
I am trying to update a user's database information once his session has expired, but it is not working. (I want to update the record "online" to 0 to indicate that the user is not online anymore) Here is the code in the Global.asa file that I am using: Sub Session_OnEnd if session("nickname")<>"" and session("password")<>"" then Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/db/members_97.mdb")) Sql = "Select * From member_table Where nickname='"& session("nickname") & "' AND password = '"& session("password") & "'" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open Sql, Conn, 3, 3 sql = "Update member_table Set online='0'" sql = sql & "where nickname='" & session("nickname") & "'" set Rs = Conn.Execute(sql) end if End Sub Any help would be much appreciated, thank you! Aaron Lacey -- Aaron Lacey
|
Tue, 24 Dec 2002 03:00:00 GMT |
|
 |
R. A. Rivas Dia #5 / 13
|
 Why isn't this working?
Also... are yu sure that is a good practice to put this info. in the database? if for some reason the server crashes, your database will have erroneous values.... if you want to have this info visible to everybody I think you should put it in an application variable. hope it helps rivas
Quote: > Server.MapPath does not work in Session_OnEnd. Map it in the > Session_OnStart, then store it in a Session Variable. > Barry > (Hardly a SQL question though, watch the cross posts please)
|
Tue, 24 Dec 2002 03:00:00 GMT |
|
 |
Aaron Bertrand [MVP #6 / 13
|
 Why isn't this working?
(a) server.mappath is unavailable in session_onEnd (b) why are you using a recordset for anything? Do this: if ... set conn = ... conn.open ... conn.execute "update member_table set online='0' where..." end if ...to accomplish the same thing much quicker. Remember that session_onEnd does not always fire... -- _______________________ MVP / www.aspfaq.com
I am trying to update a user's database information once his session has expired, but it is not working. (I want to update the record "online" to 0 to indicate that the user is not online anymore) Here is the code in the Global.asa file that I am using: Sub Session_OnEnd if session("nickname")<>"" and session("password")<>"" then Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/db/members_97.mdb")) Sql = "Select * From member_table Where nickname='"& session("nickname") & "' AND password = '"& session("password") & "'" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open Sql, Conn, 3, 3 sql = "Update member_table Set online='0'" sql = sql & "where nickname='" & session("nickname") & "'" set Rs = Conn.Execute(sql) end if End Sub Any help would be much appreciated, thank you! Aaron Lacey -- Aaron Lacey
|
Wed, 25 Dec 2002 03:00:00 GMT |
|
 |
Aaron Lace #7 / 13
|
 Why isn't this working?
Great advice, I am learning more and more every day. Do you have any advice on how I can update the record "online" equal to 0 when the user's session has ended? -- Aaron Lacey Web Development Director
www.2bros.com
Quote: > (a) server.mappath is unavailable in session_onEnd > (b) why are you using a recordset for anything? Do this: > if ... > set conn = ... > conn.open ... > conn.execute "update member_table set online='0' where..." > end if > ...to accomplish the same thing much quicker. Remember that session_onEnd > does not always fire... > -- > _______________________ > MVP / www.aspfaq.com
> I am trying to update a user's database information once his session has > expired, but it is not working. > (I want to update the record "online" to 0 to indicate that the user is not > online anymore) > Here is the code in the Global.asa file that I am using: > Sub Session_OnEnd > if session("nickname")<>"" and session("password")<>"" then > Set Conn = Server.CreateObject("ADODB.Connection") > Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & > Server.MapPath("/db/members_97.mdb")) > Sql = "Select * From member_table Where nickname='"& session("nickname") > & "' AND password = '"& session("password") & "'" > Set Rs = Server.CreateObject("ADODB.Recordset") > Rs.Open Sql, Conn, 3, 3 > sql = "Update member_table Set online='0'" > sql = sql & "where nickname='" & session("nickname") & "'" > set Rs = Conn.Execute(sql) > end if > End Sub > Any help would be much appreciated, thank you! > Aaron Lacey > -- > Aaron Lacey
|
Wed, 25 Dec 2002 03:00:00 GMT |
|
 |
Aaron Lace #8 / 13
|
 Why isn't this working?
Barry, how would I map that out in the Session_OnStart and store it in a session variable? -- Aaron Lacey Web Development Director
www.2bros.com
Quote: > Server.MapPath does not work in Session_OnEnd. Map it in the > Session_OnStart, then store it in a Session Variable. > Barry > (Hardly a SQL question though, watch the cross posts please)
|
Wed, 25 Dec 2002 03:00:00 GMT |
|
 |
Aaron Bertrand [MVP #9 / 13
|
 Why isn't this working?
sub session_onStart session("dbpath") = server.mappath("/db_path.mdb") end sub -- _______________________ MVP / www.aspfaq.com
Quote: > Barry, > how would I map that out in the Session_OnStart and store it in a session > variable? > -- > Aaron Lacey > Web Development Director
> www.2bros.com
in
> > Server.MapPath does not work in Session_OnEnd. Map it in the > > Session_OnStart, then store it in a Session Variable. > > Barry > > (Hardly a SQL question though, watch the cross posts please)
|
Thu, 26 Dec 2002 03:00:00 GMT |
|
 |
Aaron Lace #10 / 13
|
 Why isn't this working?
Awesome... after a week of working on this, I've finally got it functioning correctly. Thank you for all your help and patience! This is what learning is all about. Aaron Lacey -- Aaron Lacey Web Development Director
www.2bros.com
Quote: > sub session_onStart > session("dbpath") = server.mappath("/db_path.mdb") > end sub > -- > _______________________ > MVP / www.aspfaq.com
> > Barry, > > how would I map that out in the Session_OnStart and store it in a session > > variable? > > -- > > Aaron Lacey > > Web Development Director
> > www.2bros.com
wrote > in
> > > Server.MapPath does not work in Session_OnEnd. Map it in the > > > Session_OnStart, then store it in a Session Variable. > > > Barry > > > (Hardly a SQL question though, watch the cross posts please)
|
Thu, 26 Dec 2002 03:00:00 GMT |
|
 |
Kirill Semeno #11 / 13
|
 Why isn't this working?
I have had a lot of trouble with that -- why doesn't Session_OnEnd not always fire? Does anyone know?
Quote: > (a) server.mappath is unavailable in session_onEnd > (b) why are you using a recordset for anything? Do this: > if ... > set conn = ... > conn.open ... > conn.execute "update member_table set online='0' where..." > end if > ...to accomplish the same thing much quicker. Remember that session_onEnd > does not always fire... > -- > _______________________ > MVP / www.aspfaq.com
> I am trying to update a user's database information once his session has > expired, but it is not working. > (I want to update the record "online" to 0 to indicate that the user is not > online anymore) > Here is the code in the Global.asa file that I am using: > Sub Session_OnEnd > if session("nickname")<>"" and session("password")<>"" then > Set Conn = Server.CreateObject("ADODB.Connection") > Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & > Server.MapPath("/db/members_97.mdb")) > Sql = "Select * From member_table Where nickname='"& session("nickname") > & "' AND password = '"& session("password") & "'" > Set Rs = Server.CreateObject("ADODB.Recordset") > Rs.Open Sql, Conn, 3, 3 > sql = "Update member_table Set online='0'" > sql = sql & "where nickname='" & session("nickname") & "'" > set Rs = Conn.Execute(sql) > end if > End Sub > Any help would be much appreciated, thank you! > Aaron Lacey > -- > Aaron Lacey
|
Sat, 28 Dec 2002 03:00:00 GMT |
|
 |
Gregory Suvalia #12 / 13
|
 Why isn't this working?
I guess becouse HTTP is stateless by default and in order to fire Session_onend it shall be explicetely called by Session.Abandon if somebody just closes the browser - IIS does not catch that kind of Session ending. -- Greg
Quote: > I have had a lot of trouble with that -- why doesn't Session_OnEnd not > always fire? Does anyone know?
|
Sat, 28 Dec 2002 03:00:00 GMT |
|
 |
Michael Harri #13 / 13
|
 Why isn't this working?
But it does fire eventually... I've used it to clean up session id based temp files. -- Michael Harris MVP Scripting
I guess becouse HTTP is stateless by default and in order to fire Session_onend it shall be explicetely called by Session.Abandon if somebody just closes the browser - IIS does not catch that kind of Session ending. -- Greg
Quote: > I have had a lot of trouble with that -- why doesn't Session_OnEnd not > always fire? Does anyone know?
|
Sat, 28 Dec 2002 03:00:00 GMT |
|
|