General discussion

Locked

Too many writes at once in page tracking app?

By davidlee ·
Hi everyone!

I'm trying to implement a page tracking solution using ASP and SQL 2000. It basically writes a new record to a table every time a user visits a page on the site. It appeared to work fine at first, then I've increasingly been getting time out errors on my pages -- all pointing to the include file that fires the database write.

Here's the code that's referenced on every page:

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=x;uid=y;pwd=z;"

Set objRecordset1= Server.CreateObject("ADODB.Recordset")
objRecordset1.Open "SELECT * FROM table",Conn,1,2
objRecordset1.AddNew
objRecordset1.Fields("PAGE") = Left(request.servervariables("SCRIPT_NAME"),100)
objRecordset1.Fields("QUERY_STRING") = Left(request.servervariables("QUERY_STRING"),100)
objRecordset1.Fields("DATE") = Date()
objRecordset1.Fields("TIME") = Time()
objRecordset1.Fields("PLATFORM") = Left(request.servervariables("HTTP_USER_AGENT"),100)
objRecordset1.Fields("REFERRER") = Left(request.servervariables("HTTP_REFERER"),100)
objRecordset1.Fields("USER_IP") = Left(request.servervariables("REMOTE_ADDR"),20)
If Request.Cookies("TEST")("ID")<>"" Then
objRecordset1.Fields("VISITOR_ID") = Request.Cookies("TEST")("ID")
End If
objRecordset1.Update

Conn.Close
Set Conn=Nothing
%>

After taking out the reference to the above code everything speeds back up. So, I know the performance hit and time out issues have to do with the code above.

Is it the simultaneous write to the table, the constant opening and closing of the recordset, the cursor type, the lock type ? or combination of things?

HELP!!

Thanks!

David

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Back to Software Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums