Why isn't this working? 
Author Message
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 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  
 
 [ 13 post ] 

 Relevant Pages 

1. Why isn't this working?

2. why isn't this working

3. Why isn't this working??

4. Why isn't this working?

5. why isn't this working?

6. Why isn't this working

7. Why isn't his working correctly...?

8. Why isn't this working? - mailing with outlook

9. Why isn't this working!! Help!!!

10. SHELL command within VB5. WHY ISN'T IT WORKING

11. Why isn't my code working?

12. Why isn't my filter working in the Common Dialog ShowOpen Function

 

 
Powered by phpBB® Forum Software