Closing Recordsets/Connections

C

CJM

Is it sufficient to Set a Connection or Recordset to Nothing, or ought they
specifically be closed first?

E.g.

Set rs = oConn.Execute(sSQL)

'Do stuff

Set rs = Nothing
Set oConn = Nothing
 
C

CPrice79

I would explicitly call close on both the rs and conn objects.

Example:
if IsObject(rs) then
if not rs is Nothing Then
if rs.state <> 0 then
rs.close
end if
end if
end if
 
Y

Yan-Hong Huang[MSFT]

Hello CJM

I agree with CPrice here. It is better to close it directly instead of just
setting it to nothing. There are some network connection opened when using
RS and Connection object. Using close method can close the network
connection and clean the resource.

Thanks.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://msdn.microsoft.com/subscriptions/managednewsgroups/

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top