Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Recordset Error

Status
Not open for further replies.

Bobs390

Technical User
Aug 4, 2004
13
GB
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!

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

%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top