Unless I'm mistaken .NET connections are pooled for you, so I don't think you'll be gaining much from keeping one instance of the connection always open as the framework is already doing just that. My advice is don't worry about it until you have to... chances are it won't be a problem in the real world!


On 20/08/2012 22:01, Philippe Grohrock wrote:

    Be carefull about this way of working with DB. You must free the
    connections as fast as you can and I'm not sure you can do like
this way.

Basically the connection gets initialised when the application starts and every time I need a query, the connection gets opened, queried, closed, but not disposed. Connection.dispose() happens right before the application quits

    What happen if you dispose the connection ? That would be the
    usual way of freeing the queue (or thru the 'using' blocks).


My idea was to never dispose the connection to make the code a bit lighter. That way I don't have to re-initialise the connection each time I need a single query. Instead I have one connection with pooling enabled that gets opened and closed when I need it.

Now my problem is, that even there I'm not sure if this is a good way of dealing with that problem, it's just the idea to not create and dispose the connection for each query that lead me to do things this way. But in the end, does that even make a difference in terms of connection speed and resource usage?

Forgive me for asking such basic questions, but when it comes to organisation of code and using resources wisely I'm still learning.

------------------------------------------------------------------------
View this message in context: Re: Questions about coding style <http://mono.1490590.n4.nabble.com/Questions-about-coding-style-tp4656301p4656325.html> Sent from the Mono - General mailing list archive <http://mono.1490590.n4.nabble.com/Mono-General-f1490591.html> at Nabble.com.


_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to