For Programmers: Free Programming Magazines  


Home > Archive > ASP > July 2004 > need help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need help
Savas Ates

2004-07-31, 8:55 am

i have a website... when a user sign up my site

sql="UPDATE users set status=1 WHERE userid = '&username&';"

but when a user leave my site i want to adjust status as =0 in my database
and when user click another user he must see his status


to make this onsession end and on application .end i used codes below.. but
it doesnt workk. what is the problem. i look at aspfaq.com but i didnt find
any solution... how can i solve this problem.. with any different idea??
help me please..



Sub Application_OnEnd
set sodb = Server.CreateObject("ADODB.Connection")
sodb.Open "PROVIDER=SQLOLEDB;Initial Catalog=friends;User Id=sa
;password=;Data Source=localhost"
Set cmdTemp = Server.CreateObject("ADODB.Command")
cmdTemp.CommandType = adCmdText
Set cmdTemp.ActiveConnection = sodb
cmdtemp.CommandText = "UPDATE users set status=0 WHERE userid = 'savas';"
set setUserOffline = Server.CreateObject("ADODB.Recordset")
setUserOffline.Open cmdTemp, , adOpenStatic, adLockOptimistic
sedb.close
set sodb = nothing
End Sub


Sub Session_OnEnd 'Runs when a user's session times out or quits
your application
set sodb = Server.CreateObject("ADODB.Connection")
sodb.Open "PROVIDER=SQLOLEDB;Initial Catalog=friends;User Id=sa
;password=;Data Source=localhost"
Set cmdTemp = Server.CreateObject("ADODB.Command")
cmdTemp.CommandType = adCmdText
Set cmdTemp.ActiveConnection = sodb
cmdtemp.CommandText = "UPDATE users set status=0 WHERE userid = 'savas';"
set setUserOffline = Server.CreateObject("ADODB.Recordset")
setUserOffline.Open cmdTemp, , adOpenStatic, adLockOptimistic
sedb.close
set sodb = nothing
End Sub


dlbjr

2004-07-31, 3:55 pm

<SCRIPT language="vbscript" runat="server">
Sub Application_OnStart()
Application("CONN_STRING") = "PROVIDER=SQLOLEDB;Initial Catalog=friends;"&_
"User Id=sa;password=;Data Source=localhost"
Sub Application_OnEnd()
EndStatus "savas"
End Sub

Sub Session_OnStart()
EndStatus "savas"
End Sub

Sub Session_OnEnd()
EndStatus "savas"
End Sub

Sub EndStatus(strUserID)
strSQL = "UPDATE users set status=0 WHERE userid='" & strUserID & "';"
Set cmd = CreateObject("ADODB.Command")
cmd.CommandType = adCmdText
cmd.CommandText = strSQL
Set Conn = CreateObject("ADODB.Connection")
Conn.Open Application("CONN_STRING")
cmd.ActiveConnection = Conn
cmd.Execute
Set cmd = nothing
Set Conn = nothing
End Sub
</SCRIPT>

dlbjr
Pleading sagacious indoctrination!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com