Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Sessions and Database


Message #1 by "Derek Halstead" <derekhalstead@u...> on Mon, 14 Aug 2000 7:19:19
Hi,

   i am using sessions for the first time in my life. So when a user logs 

on to my site i want to update my table field "UserLogged" to 1.  I can 

manage to do that without using sessions and the global.asa file. But now 

the tricky part. I want to set that value which is now 1 to 0. So i am 

trying to do this in the global.asa in the Sub session_onend. What i am 

doing is i create a ADODB.Connection and with the help of a sql statement i 

update that field to 0 according to the userid. But i don't know why it 

just won't update it. I am using IIS and an access database for testing.



This is the code that i am using :-



Sub Session_OnEnd

 

set objConnection1 = Server.CreateObject("ADODB.Connection")

		 

objConnection1 = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = "& 

Server.MapPath("Clients.mdb")

		 

set objRecordset1 = Server.CreateObject("ADODB.Recordset")

		 

objSql1 = "Update ClientInfo set ClientLoggedIn=2 where ClientID = "& 

session("UserNo")

		 

objRecordset1.Open objSql1, objConnection1

		     

End Sub



Can anyone tell me if this is right or wrong and also a better solution if 

possible. Thank you.

Derek Halstead


  Return to Index