Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Without seeing your code, it is impossible to give a definitive answer; It <em>could</em> be the case that you aren't tidying up your database connections quickly enough.</p> <p>If you've something like:</p> <pre><code> While( True ) Dim con as new SqlConnection(connectionString) con.Open() Dim cmd as New SqlCommand("usp_getJob", con) cmd.CommandType = CommandType.StoredProcedure Dim dr as SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.SingleRow Or CommandBehavior.CloseConnection) If( dr.Read() ) DoSomething(dr) Else Thread.Sleep(10) End If End While </code></pre> <p>...then it will open connections faster than they will go away by themselves.</p> <p>There are several alternates, and I'd advocate using <code>Using</code> blocks to allow the connection to be returned to the connection pool as fast as possible:</p> <pre><code> While( True ) Using con as new SqlConnection(connectionString) con.Open() Using cmd as New SqlCommand("usp_getJob", con) cmd.CommandType = CommandType.StoredProcedure Using dr as SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.SingleRow Or CommandBehavior.CloseConnection) If( dr.Read() ) DoSomething(dr) dr.Close() Else Thread.Sleep(10) End If End Using End Using End Using End While </code></pre> <p>These will then call <code>Dispose()</code> on the <code>SqlDataReader</code>, <code>SqlConnection</code> and <code>SqlCommand</code> - either of the first two will cause the connection to be released to the connection pool (given we've asked the <code>SqlDataReader</code> to <code>CloseConnection</code> on its close)</p>
 

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