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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Connection = Nothing 2

Status
Not open for further replies.

Akart

IS-IT--Management
Nov 14, 2002
71
AU
Hey there,

I have been creating an access project between access and sql server and all the times i have made an adodb.connection etc i have never set:

adodb.connection = Nothing
or adodb.connection.close


I still don't know why people add close to their code. What will happen when my system is being used by 30 people? Will not closing all the connections stuff up the sql server?

Please enlighten me so i can change my evil ways (If necessary) =)

Thanks,
Akart
 

dim cn as New adodb.connection '- creates the object
dim rs as New adodb.connection '- creates the object

'- the New keyword creates an instance of the object and takes up memory.

rs.close '- closes the recordset but memory is still used
Set rs = Nothing '- releases the memory used up

cn.close '- closes the connection but a recordset on the connection can still be in memory and worked on. Also, the connection can be reopened and the in memory recordset can update the source.

Set cn = Nothing '- releases the memory

You should destory all objects when finished with them, they will definitely take up memory otherwise - that is any type of object you create.
 
Thanks cmmrfrds,

That makes sense. Luckily i am in the early stages so i can go add in these changes =)

Akart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top