Click to See Complete Forum and Search --> : Removing a record from the database on browser close.


telmessos
06-02-2008, 06:41 AM
Hi All,

I use the following code in Global.asa file to remove one of the records in the database in case of browser close or any kind of powercut. For some reason it doesn't work. I also tried to make it without RecordSet it didn't work. Do I have to give some permissions to Global.asa (it has read access for Anonymous User as explained in Microsoft site.)

Thanks


My code is :

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Sub Session_OnStart

Session("strSessionID")=Session.SessionID

End Sub

Sub Session_OnEnd()
SET DbObj=Server.CreateObject("ADODB.CONNECTION")
DSNName="Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=rental;Uid=root;Pwd=xxxxxxxx;"
DbObj.Open DSNName
strSessionID = Session("strSessionID")
Set rsInterfaceLogins = Server.CreateObject("ADODB.Recordset")
sessionSQL = "Select * from booking where sessionID='" & strSessionID & "'"
rsInterfaceLogins.Open sessionSQL, DbObj, , adLockPessimistic
rsInterfaceLogins.Delete

rsInterfaceLogins.Close
Set rsInterfaceLogins = Nothing
DbObj.Close
Set DbObj=Nothing
End Sub
</SCRIPT>