Tuesday, December 11, 2007

Classic ASP...is that Connection object or Recordset Object Closed?

To say some of the legacy code that I'm working is Sphagetti code would be an understatement, it is more like a pasta house. Include after include after include. To be honest, I actually like coding like that sometimes...I know, blasphemy to the OO crowd. But in many ways our site has grown out of control. Open connections, recordsets not being closed, yadda yadda yadda.

So I found this cool article

So, I have this include file that opens all these recordsets and command objects. On some pages these objects are closed, on others not. So a quick fix to make sure these objects were closed so the SQL server wasn't being killed and our server memory maxing out was something like this...

if isObject(someobj) then
if not (sombobj is nothing) then
if someobj.state = 1 then
end if
set someobj= nothing
end if
end if

This should pin things till the rewrite, or until I go through and really tiddy up the code. someobj can be either an ADODB recordset or an ADODB connection. For command objects just remove the if somebj.state if then and it should work.

No comments: