Re: ODP .Net Connection Pool Problem on Web Application



I have seen a very similar issue come up when using SQL connection and
leaving them open. It is possible that only one connection in your
code fails to close the connection, but if that piece of code is
executed several times over, you will receive this error.

I have run into this problem when using data readers for fetching SQL
records. Any time you open a connection or use a data reader, it must
be followed by a Close call. Interestingly enough, I was occasionally
still receiving errors of the sort. I determined the error to be
caused by exceptions thrown while in the midst of a connection; I now
wrap any data reader connection as follows:

SqlDataReader dr = null;
try {

// SQLHelper - Microsoft Data access App.
dr = SQLHelper.ExecuteReader (....);
while (dr.Read ()) {

_myStrings.Add (dr.GetString(0));
_myInt.Add (dr.GetInt32(1));
}
dr.Close();
}
catch {

dr.Close ();
throw;
}

In some cases, I will simply put a finally block that has the
dr.Close() in it, but only if I don't care to re-throw the exception.
Anyway, I recommend you ensure anywhere you open a connection, you
close it. .NET does not close them when the object goes out of scope.

.



Relevant Pages

  • RE: SqlDataReader Function From a VB6 refugee
    ... After you return the data reader you are closing the connection: ... But the data reader needs the connection to stay open until you have ... Shared Function Create_SQL_DataReader(ByVal sDate As String) As ... Dim SQLConn As New SqlConnection ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: A few thousands simple queries seem to clog SQL server (for a while)
    ... You are connecting multiple times to the database, ... You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik ... > sure I close each and every data reader before opening a new one. ... > keep the connection to the database open for the duration of the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: which is a better use of the data
    ... that would use another connection. ... Your clients then can make all thier changes ... If performance in terms of memory is an issue, ... > reason i wouldnt use a data reader and use concurrent updates/inserts ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ADO.NET & MS SQL 2000 - General Network Error
    ... >communicates with my SQL Server locally (LAN). ... > The ONLY variable in the equation is LAN vs. Broadband connection. ... > reader is always somehow involved -- it is as if the data reader ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ADO vs. ADO.NET
    ... ADO has the same inability as ADO.NET to do parallel work on the same open ... What it does is to open a second, hidden connection when you ... > to a global variable (recordset). ... > other database operations to the connection unless the data reader is ...
    (microsoft.public.dotnet.general)