I've got quite a large ASP driven site, and I suspect that not closing my connection objects to a mySQL database is occasionally causing problems.

Every page uses a standard footer which I could build code into to automatically close these connections ( I'm a creature of habbit and always call them the same thing) but to make it work smoothly I really need to be able to check if the object exists in the first place as its possible that most times the code above the footer would have closed it correctly anyway.

I know this is a bit of a 'fix' and I should really sort them all out by hand, but I thought if I got this automatic way of doing working first it would buy me some time and I could get it to log the pages with problems.

The kind of thing I am looking for is...

if exists(myConnection) then
myConnection = nothing

where myConnection is the connection object.

Any help would be great.