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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Objects / Connections/ Recordsets

Status
Not open for further replies.

emblewembl

Programmer
May 16, 2002
171
GB
I have a question about closing recordsets, connections etc. An old colleague of mine wrote a sub routine which is used to 'kill' any object. The sub is as follows:
Code:
Sub KillObject(ByRef objToKill)

 On Error Resume Next
	
 objToKill.Close
 Set objToKill = Nothing
	
 Err.Clear
			   
End Sub
So to kill a connection that is called objConn, for example, you would put in your page:
Code:
Call KillObject(objConn)

Can you all tell me if this code is ok - I want to reuse in a new project if it is. Also I know you should always close a recordset or a connection, but what about if you create an instance of the MSWC.Contentrotator? Should this be 'killed' too? And what about the MSWC.BrowserType object?

Hope you can enlighten me! i love chocolate
 
This sub will "work" for all objects because of the
Code:
"on error resume next"
and
Code:
"err.clear"
that will trap any error. Water is not bad as soon as it stays out human body ;-)
 
Ok, thanks for clearing that up Targol. i love chocolate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top