In VB6.0 I used to open just one public Connection object and use it in all my recordsets, is it still advisable to employ such strategy in ADO.Net?
Printable View
In VB6.0 I used to open just one public Connection object and use it in all my recordsets, is it still advisable to employ such strategy in ADO.Net?
Con obj creation is a resource consuming .Although , conn objs that have the same conn strings are pooled but they consume resources the moment they're created.
It seems that didnt clarify things on my original query? :( Should I use one public Connection object in ADO.Net or create it as it is needed? Or it will depend upon the database I am interacting with if it is Access or SQL Server?
Using a single database connection is a good idea in my opinion. You would not leave it open when not in use, however.
Hmmmnnn... Then I should close and open it as it is needed?Quote:
Originally Posted by jmcilhinney
Use 1 glolabl connection obj , close it when you're done . Add this to my previous post !
Same question thrown at jmcilhinney, should I close and open it as it is needed? In VB6.0 I used to make it stay opened... What would be the issues if I'll leave it open?
Like everything, you should reduce the access to a connection to only what you need. Also, you are tying up a resource while the connection is open.
I cant seem to understand it, could you elaborate on it?Quote:
Originally Posted by jmcilhinney
An open connection is like an open door: anyone can go in or out at any time. It would be considered "more correct" to only open the door when it is necessary.
:) That is a nice illustration there. :thumb: