Is it necessary to close an Adodb.recordset object before setting it to nothing?

后端 未结 4 1460
猫巷女王i
猫巷女王i 2021-02-13 19:05
Dim rs as ADODB.Recordset
set rs = ReturnARecordset \'assume ReturnARecordset does just that...

\'do something with rs

rs.Close
set rs = Nothing

Is i

4条回答
  •  既然无缘
    2021-02-13 20:05

    Yes, this does more than just force a garbage collection it also tells the server the connection is being terminated, this avoids having multiple open orphaned connections (they will eventually time-out by themselves) but its always best practise to close them out.

    This is especially apparent when ADODB is using a remote connection rather than a local one.

提交回复
热议问题