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

RS. Close and Set RS = nothing

Status
Not open for further replies.

cyberbiker

Programmer
Mar 16, 2001
431
US
I have always closed recordsets before setting them to nothing (learned to set rs = nothing the hard way I must admit) but....

currently I do this

RS.close
set RS = nothing

My experimenting shows no reason not to just:

set RS = nothing

Is it really necessary to close a recordset before setting it to nothing? If so can somebody explain why?

Terry (cyberbiker)
 
My understanding (for what that is worth) is that when you set RS=NOTHING you not only close the connection to the DB you destroy the recordset object and that is the difference. You will no longer have access to the object, in other words it is not available to be reopened. But I must admit that I am an old fashioned programmer who (out of habit) codes:

RS.Close
set RS=nothing
 
Thank you.

I do understand the difference between closing a recordset and destroying a recordset object and I also understand the need to clean up by destroying the recordset object.

I also close a recordset out of habit and was just wondering if closing is necessary or desireable before destroying the object. And if it is desireable to close the recordset first, why?.

Everbody I know seems to do it this way, but no one seems to know quite why.

Terry (cyberbiker)
 
I don't know particularly why either, but I know when I use the getrows method after opening a recordset, that I cannot open another recordset in the same procedure without closing the first one as well as setting it = nothing. Just a thought.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top