Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do I need to close a RS or Connection before Set it to Nothing

Status
Not open for further replies.

asuknow

Programmer
Sep 28, 2001
26
US
Do I really need to use RS.close before I
Set RS=Nothing ?
Does this apply to database conneciton as well?

What can be the consequence if I set a RS (or a db connection) to Nothing directly without closing it?

Another puzzle, for example:
After a RS is opened by Set RS=dbconn.execute(sql)
I close RS and set RS=Nothing, and I also close the
database connection by dbconn.close.
But I have some ASP scripts afterwards to determine
whether dbconn is existed or not, if yes, I close the
database connection and set dbconn to nothing, here's the
example:
....
Line1 dbconn.close
line2 Set dbconn=Nothing
Line3 If IsObject(dbconn) then
Line4 dbconn.close
Line5 Set dbconn=Nothing
Line6 end if

But an error would occur saying that an object is required
in line4, how can line4 still be executed if I've
delete the object in Line2????

Thank you for any help!
 
I'm not sure, I've never used the conditional statement isObject() before. However, setting the connection or the recordset to nothing should be all you have to do. No need to issue a close statement.

As far as I know :)

TW
 
I don't think you really need to close it before setting it to Nothing, but I think it'd be good practice.
[tt]
If Not adoRS Is Nothing Then
[tab]If adoRS.State = adStateOpen Then
[tab][tab]adoRS.Close
[tab]End If
[tab]Set adoRS = Nothing
End If
[/tt]

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top