For Programmers: Free Programming Magazines  


Home > Archive > ASP > January 2006 > Closing Recordsets/Connections









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Closing Recordsets/Connections
CJM

2006-01-31, 7:55 am

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.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com