Whats the difference between rs.close vs rs = nothing in a RecordSet

Curtis Inderwiesche picture Curtis Inderwiesche · Mar 30, 2010 · Viewed 26k times · Source

I often find it confusing as to when it is appropriate to use:

rs.Close 

opposed to

Set rs = Nothing

I can understand needing to close a connection to a source, but should I be using both when the variable falls out of scope?

Can I just set the variable to Nothing in order to skip the step of Closing the connection? Would this be considered a bad practice?

Answer

Jojo Sardez picture Jojo Sardez · Mar 30, 2010

By using the "Close" method you are closing the connection to the database but is still in the memory where you can open again using the "Open" method.

Setting the recordset to "Nothing" on the other hand releases the object completely from the memory.