[Mono-list] Questions about coding style

James Wright james.wright at jigsawdezign.com
Mon Aug 20 21:05:50 UTC 2012

   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 at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20120820/08bb2f6b/attachment-0001.html>

More information about the Mono-list mailing list