I am using the code below to track hits from banners, It works but if I use the RS.Close at the end to close the recordset object it throws up an error:
Operation is not allowed when the object is closed.
/click/clicks/redirect.asp, line 23
But if I remove the RS.Close the it works fine ?!?
Why does it do this and is it a problem if I just delete it?
Many Thanks again!
Operation is not allowed when the object is closed.
/click/clicks/redirect.asp, line 23
But if I remove the RS.Close the it works fine ?!?
Why does it do this and is it a problem if I just delete it?
Many Thanks again!
Code:
<%
SiteURL = Request.QueryString("URL")
site = Request.QueryString("site")
city = Request.QueryString("city")
Set DataConn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
DataConn.Open "DBQ=" & Server.Mappath("clicks.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set rsInfo = DataConn.Execute("SELECT * from SiteClicks WHERE site = '" & site & "' AND city = '" & city & "'")
If rsInfo.EOF Then
SQL = "INSERT INTO SiteClicks (site,city,thisdate,clicks) VALUES('" & site & "' , '" & city & "', '" & date & "', 1);"
Set rsInfo = DataConn.Execute(SQL)
Response.Write "<CENTER>Record Updated!<br>"
Else
'"UPDATE SiteClicks SET clicks = clicks + 1, thisdate = '"&NOW()&"' WHERE (site='...') AND (city='...')"
SQL = "UPDATE SiteClicks SET clicks = clicks + 1, thisdate = '"&date&"' WHERE site='" & site & "' AND city='" & city & "';"
Set rsInfo = DataConn.Execute(SQL)
Response.Write "<CENTER>2</CENTER>"
RS.Close
DataConn.Close
End If
%>