| Author |
Closing Recordsets/Connections
|
|
|
| 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
--
cjmnews04@REMOVEMEyahoo.co.uk
[remove the obvious bits]
| |
| CPrice79 2006-01-31, 7:55 am |
| 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
"CJM" wrote:
> 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
>
>
>
>
> --
> cjmnews04@REMOVEMEyahoo.co.uk
> [remove the obvious bits]
>
>
>
| |
| Yan-Hong Huang[MSFT] 2006-01-31, 9:55 pm |
| 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/subscript...agednewsgroups/
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|