Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using a single connection is an extremely bad idea - if access to the connection is properly locked, it means that ASP.NET can only serve one user at a time, which will seriously limit your application's ability to grow.</p> <p>If the connection is <em>not</em> properly locked, things can get really weird. For example, one thread might dispose the connection while another thread is trying to execute a command against it.</p> <p>Instead of using a single connection, you should just create new connection objects when you need them, to take advantage of connection pooling.</p> <p>Connection pooling is <a href="http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx" rel="nofollow noreferrer">the default behavior for the SqlClient classes</a> (and probably other data providers). When you use connection pooling, any time you 'create' a connection, the connection will actually be pulled from a pool of existing ones so that you don't incur the costs of building one from scratch each time. When you release it (close it or dispose of it) you return it to the connection pool, keeping your total count of connections relatively low.</p> <hr> <p>Edit: You'll see the error you mention (<em>The timeout period elapsed prior to obtaining a connection from the pool</em>) if you're not closing (or disposing) your connections. Make sure you do that as soon as you're done using each connection.</p> <p>There are several good stack overflow questions that discuss this, which I suspect might be helpful!</p> <ul> <li><a href="https://stackoverflow.com/questions/1552571/why-isnt-sqlconnection-disposed-closed">Why isn’t SqlConnection disposed/closed?</a></li> <li><a href="https://stackoverflow.com/questions/141204/what-is-the-proper-way-to-ensure-a-sql-connection-is-closed-when-an-exception-is">What is the proper way to ensure a SQL connection is closed when an exception is thrown?</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload