Click to See Complete Forum and Search --> : Code executed on conclusion of page


Vic
08-09-2006, 07:29 AM
I was just wondering, is there any system - function that is called right at the end after a page had been formed via ASP / VB? For example, as I prepare my page I create a DB connection (which is standardised through reference to a Server-Side-Include page), which I would like to close once the page is finished preparing (i.e. "Set myConn = Nothing"). Rather than placing this piece of code at the end of my ASP code, I would prefer to include it in my SSI page and have it automatically executed once the page is done. Any thoughts?

PS. Btw, on a different matter, is it really necessary to close my connection explicitly by setting it to "Nothing", or would this be done anyway by the server once the page is complete and dispatched?

thanks a lot in advance...

russell
08-09-2006, 09:42 AM
You can create an ASP Class file and use the Class_Terminate() method which is always fired at the end of execution.

YES! ALWAYS explicitly close and destroy your objects. They will eventually be freed but it is extremely poor practice not to do so, and a bit of a waste of system resources -- especially with db connections