Click here to Skip to main content
15,904,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What performs best: (OleDbConnection)
1) A Closed Connection object assign to a global variable and Open it when need
Or
2) A Opened Connection object assign to a global variable and keep it throughout the application
Or
3) Everytime creates a new local Connection object and close it after use
Or
4) Anything other suggestion(s)

The main objectives: The best ferformance
Posted

1 solution

Every time creates a new local Connection object and close it after use.

This is a homework question. This was given to you to tell what is way to create the connection object such that there is no memory leakage. Thus, keeping it local and open when needed and close after use is the best way to make least memory issue because of open connection.
 
Share this answer
 
Comments
Albin Abel 21-Mar-11 1:54am    
:) my 5
jdebabrata 22-Mar-11 9:05am    
Sandeep Mewara
Thank you very much for your opinion.
What about "A Closed Connection object assign to a global variable and Open it when need and after use, just close it". I think, it also serves well.

jdebabrata
Sandeep Mewara 22-Mar-11 11:16am    
It does but, it's scope is global and thus will be dangling for more time than a local one.
jdebabrata 22-Mar-11 11:38am    
Yes, you'r absolutely right. Thank you very much.
Sandeep Mewara 22-Mar-11 12:13pm    
Thanks! Kindly close the question now by accepting the answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900