function to delete in global.asa

Results 1 to 3 of 3

Thread: function to delete in global.asa

  1. #1
    Join Date
    Dec 1969

    Default function to delete in global.asa

    hello<BR><BR>I &#039;m some days with this problem and I don&#039;t know why ocurrs it.<BR><BR>I&#039;d like to delete some registers from my db when a user disconnects<BR>(Session_onEnd) but it doesn&#039;t execute. I have this code<BR>in the global.asa<BR><BR><BR>Sub Session_OnStart<BR> application.lock<BR> application("visit")=application("visit")+1<BR> application.unlock<BR> session ("autoriced")=0<BR> session ("CadenaConexion") ="DSN=loca;Initial Catalog =pruesbas; UID=sa;<BR>password=; "<BR> miCN.ConnectionString = session("CadenaConexion")<BR>end sub<BR><BR>function deletee (id)<BR> miCN.Open<BR> sql= "select from usuarios where tipo= &#039;"&id&"&#039;"<BR> Mirs.CursorType=1<BR> Mirs.LockType=2<BR> MiRs.Open sql,MiCn<BR> &#039;delete<BR> Mirs.Delete<BR> &#039;update<BR> Mirs.Update<BR> Mirs.Close<BR> end function<BR><BR>Sub Session_OnEnd<BR> application.lock<BR> application ("visit")=application ("visit")-1<BR> application.unlock<BR> if Session ("autoriced")=3 and Application (Session<BR>("nbusuario"))=connected then<BR>&#039;ON THESE CONDITIONS ARE WHEN I HAVE TO DELETE USERS<BR> application.lock<BR> Application (Session ("nbusuario"))="disconnected"<BR> application.unlock<BR> deletee (1)<BR> end if<BR>end sub<BR><BR>Sub Application_OnEnd<BR><BR>end Sub<BR>&#060;/SCRIPT&#062;<BR><BR>&#060;OBJECT ID="miCN" RUNAT="SERVER" SCOPE="SESSION" PROGID="ADODB.Connection"&#062;<BR>&#060;/OBJECT&#062;<BR><BR>&#060;OBJECT ID="miRS" RUNAT="SERVER" SCOPE="SESSION" PROGID="ADODB.Recordset"&#062;<BR>&#060;/OBJECT&#062;<BR><BR>I need some help. A lot of thanks Mike<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: function to delete in global.asa

    The session doesn&#039;t end until it times out so it may take awhile from when they actually log off for this to happen. You may want to replace the Session_OnEnd to this<BR><BR>Sub Session_OnEnd<BR>set MiCN = Server.CreateObject("ADODB.Connection")<BR>MiCN.Op en session("CadenaConexion")<BR>application.lock<BR>a pplication ("visit")=application ("visit")-1<BR>application.unlock<BR>if Session ("autoriced")=3 and Application (Session("nbusuario"))=connected then<BR>sql= "delete from usuarios where tipo= &#039;"&id&"&#039;"<BR>MiCN.Execute sql<BR>application.lock<BR>Application (Session ("nbusuario"))="disconnected"<BR>application.unloc k<BR>deletee (1)<BR>end if<BR>end sub<BR><BR><BR><BR>This should work.<BR><BR><BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Session_onEnd notoriously unreliable

    I have no idea why, but many many people before you have complained that Sesssion_onEnd doesn&#039;t get triggered on any reliable basis. <BR><BR>The best you can do, probably, is trigger the equivalent code via some *other* user&#039;s onStart.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts