how many instances of SqlConnection should I use how many instances of SqlConnection should I use sql sql

how many instances of SqlConnection should I use


Don't worry about sharing to conserve resources. .NET will manage this for you, it does connection pooling by default. Write the code to be clear and understandable and let .NET take care of these details.


Create as many SqlConnections as you need, as shortly lived as possible, through the using statement:

using (var connection = new SqlConnection(...)) {  connection.Open();  ...}

Sql connections are taken from a connection pool, which will automatically manage contention for you.

See: http://msdn.microsoft.com/en-us/library/8xx3tyca(VS.80).aspx