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

Database Connection and Recordset

Status
Not open for further replies.

75cl

Programmer
Nov 1, 2001
43
US
is there any generic procuredure out there that will close any database connection and any recordsets?
 
Hi 75cl

My only suggestions are to always close modular recordsets
in a Form_Unload procedure and close any Global databases
and set them to "Nothing"

See example coding below :-


Private Sub Form_Unload(Cancel As Integer)
mrsNames.Close 'Close modular recordset
gdbCustomerRecords.Close 'Close Global database
Set gdbCustomerRecords = Nothing
End Sub

datamasher
 
That's what I have it done for my database currently. but there a so many recordsets that i have to close. I just want to know if anyone know of a better way of doing it, Like having a procedure that will close any recordset, any database connection.
 
Not knowing the complexity of your solution, I would still question the need for so many simultaneous DB connections, and open recordsets instantiated in memory.

Aside of that observation there is no standard way to dynamically close and destroy object in memory.
 
may I add...

Other than the standard:

Private Sub Form_Unload(Cancel As Integer)
oRS.Close
Set oRS = Nothing
oRS2.Close
Set oRS2 = Nothing
.
.
.
oConn.Close
Set oConn = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top