473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Elusive randomly occuring exceptions

This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.

The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:

[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

What handle????
Sometimes, I get a SemephoreFullException instead:

[SemaphoreFullException: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threading.Semaphore.Release(Int32 releaseCount) +1853063

System.Data.ProviderBase.DbConnectionPool.PutNewOb ject(DbConnectionInternal
obj) +54

System.Data.ProviderBase.DbConnectionPool.Deactiva teObject(DbConnectionInternal
obj) +228

System.Data.ProviderBase.DbConnectionPool.PutObjec t(DbConnectionInternal
obj, Object owningObject) +265

System.Data.ProviderBase.DbConnectionInternal.Clos eConnection(DbConnection
owningObject, DbConnectionFactory connectionFactory) +97
System.Data.SqlClient.SqlConnection.Close() +117
System.Data.Common.DbDataAdapter.QuietClose(IDbCon nection
connection, ConnectionState originalState) +13
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
Or sometimes I get:

[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) +734982

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParserStateObject.ThrowEx ceptionAndWarning()
+13
System.Data.SqlClient.TdsParserStateObject.WriteSn i() +638049
System.Data.SqlClient.TdsParserStateObject.WritePa cket(Byte
flushMode) +265
System.Data.SqlClient.TdsParserStateObject.Execute Flush() +51
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_Sql RPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj) +3977
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior
behavior) +12

System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader(CommandBehavior
behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:

[UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?

This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it's own application pool on the
production box for now while I'm testing.

The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).

I don't know what to do. I don't know how to troubleshoot this. Days
of googling and searching forums has not helped me.

Please help!

Jul 4 '06 #1
10 6619
Jeff,
This looks like some sort of Connection Pool error, Connection Pooling is
based on COM+ "under the hood". Can you post some sample code illustrating
how your SqlConnections are being opened and closed? Is the connection string
the same for all connections?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff Shepler" wrote:
This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.

The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:

[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

What handle????
Sometimes, I get a SemephoreFullException instead:

[SemaphoreFullException: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threading.Semaphore.Release(Int32 releaseCount) +1853063

System.Data.ProviderBase.DbConnectionPool.PutNewOb ject(DbConnectionInternal
obj) +54

System.Data.ProviderBase.DbConnectionPool.Deactiva teObject(DbConnectionInternal
obj) +228

System.Data.ProviderBase.DbConnectionPool.PutObjec t(DbConnectionInternal
obj, Object owningObject) +265

System.Data.ProviderBase.DbConnectionInternal.Clos eConnection(DbConnection
owningObject, DbConnectionFactory connectionFactory) +97
System.Data.SqlClient.SqlConnection.Close() +117
System.Data.Common.DbDataAdapter.QuietClose(IDbCon nection
connection, ConnectionState originalState) +13
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
Or sometimes I get:

[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) +734982

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParserStateObject.ThrowEx ceptionAndWarning()
+13
System.Data.SqlClient.TdsParserStateObject.WriteSn i() +638049
System.Data.SqlClient.TdsParserStateObject.WritePa cket(Byte
flushMode) +265
System.Data.SqlClient.TdsParserStateObject.Execute Flush() +51
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_Sql RPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj) +3977
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior
behavior) +12

System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader(CommandBehavior
behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:

[UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?

This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it's own application pool on the
production box for now while I'm testing.

The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).

I don't know what to do. I don't know how to troubleshoot this. Days
of googling and searching forums has not helped me.

Please help!

Jul 4 '06 #2
Jeff Shepler wrote:
This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.

The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
<snippedy-doo-dah>

Hi Jeff,

Sounds like you've got some wierd heisenbug here. Are you using threading
or asynchronous operations in your code anywhere?

--
Hope this helps,
Tom Spink
Jul 4 '06 #3
Also what security context is the app-pool runing under, and is IIS using
impersonation (based on the web-user account) - as I /believe/ the pool is
split by NT identity as well as connection string (even if not using
integrated security).

Marc

Jul 4 '06 #4
I don't have access to the code right now (Happy 4th!!), but I did
write a wrapper around the SqlConnection object for 2 purposes. One is
to use the customer connection string manager I wrote and the other is
to hide the connection properties and provide a facade for executing
queries.

As a result, the same connection object is used for all methods the
consumer uses. Originally, I kept the connection open for the duration
of the object - which was only as long as a request being processed -
thinking that it would improve performance. However, I read somehwere
(duing my searching for answers to these expections) that implied that
it wasn't a good idea to do so. So, now I open/close when needed.

If I understood what I read, just because I have a SqlConnection
object doesn't mean that I have the same connection from the pool. The
connection is aquired on .Open(), correct? Regardless, it didn't fix
the errors I was having and I did not notice any improvement in speed.

No, the connection string is not the same for all connections. The
application uses 3 databases, 2 of which are on the same server. All
have different login credentials.
From memory, here's approximately what I'm doing:

public class ManagedConnection
{
private SqlConnection conn;

public ManagedCollection(string dbAlias, string appName)
{
conn = new
SqlConnection(ConnectionStringManager.GetConnectio nString(dbAlias) +
";app=" + appName);
}

public DataSet Execute_Procedure_DataSet(string spName,
List<SqlParameterParameters)
{
SqlCommand cmd;
SqlDataAdapter sda;
DataSet ds = new DataSet();

cmd = Connection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = spName;
foreach(SqlParameter p in Parameters)
cmd.Parameters.Add(p);

sda = new SqlDataAdapter(cmd);

try
{
sda.Fill(ds);
}
catch(Exception ex)
{
throw new Exception(....customized error here showing
query and parameters for easy runtime debugging...);
}

return ds;
}
}

There are many other methods for dealing with adhoc queries,
transactional queries, queries with no result, queries with a single
result (scalar) and queries that return a value. They all basically do
the same thing.

On Tue, 4 Jul 2006 07:23:01 -0700, Peter Bromberg [C# MVP]
<pb*******@yahoo.nospammin.comwrote:
>Jeff,
This looks like some sort of Connection Pool error, Connection Pooling is
based on COM+ "under the hood". Can you post some sample code illustrating
how your SqlConnections are being opened and closed? Is the connection string
the same for all connections?
Peter
Jul 4 '06 #5
I did change the security context to LocalSystem because of the
problem with the worker process crashing on every recyle.

http://blogs.msdn.com/david.wang/arc...ASPNet_20.aspx
It's been a while since I've researched the bug. Maybe it's been fixed
by some Windows Update since then. I'll set it back to network and try
again. Or would you suggest something different?
IIS is set to integrated auth, yes. I'm not sure I follow "the pool is
split by NT identity ...". Are you saying that if user1 and user2 ask
for a connection (is the same app domain) using the exact same
connection string, they would get two different connections?
Interesting if true, but I'm not really there yet. I've been the only
one using this app so far (still under development).
On Tue, 4 Jul 2006 15:28:56 +0100, "Marc Gravell"
<ma**********@gmail.comwrote:
>Also what security context is the app-pool runing under, and is IIS using
impersonation (based on the web-user account) - as I /believe/ the pool is
split by NT identity as well as connection string (even if not using
integrated security).

Marc

Jul 4 '06 #6
No.

After I started getting the errors, I re-thought my managed connection
object and decided to make it thread-safe by locking access to the
SqlConnection object. Just in case I (or someone else) would want to
use the object in a threaded environment or as a singleton in a web
app.

However, it didn't fix the problems and I read somewhere (can't find
it right now) that it wasn't a good idea to do that - it was better to
let the connection pool handle concurrency (???). So, I removed it.

It might become a concern once this thing is to go live as, being a
web app, some of my singletons could very well (and probably will) be
accessed from multiple threads.

I'm relatively new to threading. I've done a few things with various
successes. I don't think I have a full understanding though - it
hasn't "clicked" for me yet.
On Tue, 04 Jul 2006 15:26:07 +0100, Tom Spink <ts****@gmail.com>
wrote:
>Jeff Shepler wrote:
>This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.

The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.

<snippedy-doo-dah>

Hi Jeff,

Sounds like you've got some wierd heisenbug here. Are you using threading
or asynchronous operations in your code anywhere?
Jul 4 '06 #7
Are you saying that if user1 and user2 ask
for a connection (is the same app domain) using the exact same
connection string, they would get two different connections?
If IIS is configured to switch into the user's NT identity, then my
understanding is that yes: each user would get their own pool; the pool
maximum would probably kick in quite soon such that you don't see much
benefit from pooling, but I was mainly asking to see if you were drowning in
the connection pool. Many IIS configurations use the trusted sub-system
model, with some form of access-control at the boundary, then a single NT
identity (e.g. "NETWORK SERVICE", etc) performing all access within the
system; as I understand it this will allow the pool to be shared across all
users.

I'm still not sure that this would explain the level of errors that you are
seeing; are you /sure/ the connections are closed and disposed
appropriately?

Marc
Jul 4 '06 #8
I do close, but not dispose. The class doesn't know how many times a
method is going to be called. I didn't want to create a new
SqlConnection instance for each method. I guess I could implement a
destructor in my facade class that would call conn.Dispose(). While
that might be preferred, I don't think it helps with these exceptions
that I'm getting.

However, I believe that if the pool was running out of connections,
I'd get a the timeout exception. Something like: Error connecting:
Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached.

On Tue, 4 Jul 2006 17:15:43 +0100, "Marc Gravell"
<ma**********@gmail.comwrote:
>Are you saying that if user1 and user2 ask
for a connection (is the same app domain) using the exact same
connection string, they would get two different connections?

If IIS is configured to switch into the user's NT identity, then my
understanding is that yes: each user would get their own pool; the pool
maximum would probably kick in quite soon such that you don't see much
benefit from pooling, but I was mainly asking to see if you were drowning in
the connection pool. Many IIS configurations use the trusted sub-system
model, with some form of access-control at the boundary, then a single NT
identity (e.g. "NETWORK SERVICE", etc) performing all access within the
system; as I understand it this will allow the pool to be shared across all
users.

I'm still not sure that this would explain the level of errors that you are
seeing; are you /sure/ the connections are closed and disposed
appropriately?

Marc
Jul 4 '06 #9
I'm having a problem understanding this "handle" thing.

You say the connection pooling is based on COM "under the hood". I can
accept that.. No problem.. Kinda obvious given the stack trace.. What
I don't understand is how how I use objects affects "under the hood".
I mean, I just call SqlDataAdapter.Fill(DataSet), for example, and the
exception gets thrown. The code that deals with connection pooling
isn't under my control. The framework is creating this handle, not me.
So, if the handle is invalid, then the framework is doing something
wrong???
The only thing I do to affect it is the connection string, right? If
the connection string got corrupted somehow, wouldn't one of the
objects in the chain (SqlClient.SqlConnection,
ProviderBase.DbConnectionFactory, ProviderBase.DbConnectionPool) catch
it or is it only checked on creation?
I'll spend time investigating the connection string to see if it's
getting munged somewhere along the line.
On Tue, 4 Jul 2006 07:23:01 -0700, Peter Bromberg [C# MVP]
<pb*******@yahoo.nospammin.comwrote:
>Jeff,
This looks like some sort of Connection Pool error, Connection Pooling is
based on COM+ "under the hood". Can you post some sample code illustrating
how your SqlConnections are being opened and closed? Is the connection string
the same for all connections?
Peter
Jul 4 '06 #10
Close is fine without Dispose. In fact, before a hotfix in 1.1, it was the
only way to return the connection to the pool. However, I'd consider using
the "Best practices"Pattern: Open a connection immediately before the code
the uses it, and close it immediately thereafter. With pooling most of the
overhead of connection - related semantics is alleviated.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff Shepler" wrote:
I do close, but not dispose. The class doesn't know how many times a
method is going to be called. I didn't want to create a new
SqlConnection instance for each method. I guess I could implement a
destructor in my facade class that would call conn.Dispose(). While
that might be preferred, I don't think it helps with these exceptions
that I'm getting.

However, I believe that if the pool was running out of connections,
I'd get a the timeout exception. Something like: Error connecting:
Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached.

On Tue, 4 Jul 2006 17:15:43 +0100, "Marc Gravell"
<ma**********@gmail.comwrote:
Are you saying that if user1 and user2 ask
for a connection (is the same app domain) using the exact same
connection string, they would get two different connections?
If IIS is configured to switch into the user's NT identity, then my
understanding is that yes: each user would get their own pool; the pool
maximum would probably kick in quite soon such that you don't see much
benefit from pooling, but I was mainly asking to see if you were drowning in
the connection pool. Many IIS configurations use the trusted sub-system
model, with some form of access-control at the boundary, then a single NT
identity (e.g. "NETWORK SERVICE", etc) performing all access within the
system; as I understand it this will allow the pool to be shared across all
users.

I'm still not sure that this would explain the level of errors that you are
seeing; are you /sure/ the connections are closed and disposed
appropriately?

Marc
Jul 4 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: viditm | last post by:
Hi I keep getting the error "Error Creating Windows Handle" in my application and different places in the code. This occurs only to certain users. Its very random and cannot be reproduced in the...
0
by: Chris Q. | last post by:
I am creating a custom control that contains a list view with dates and times. I need to make sure that times do not overlap. I would like the control to determine if the overlap is occuring with the...
5
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the...
1
by: Chris Ashley | last post by:
I seem to be getting an elusive Javascript error on all my ASPX pages... apparently it's on line 4, char 1, but I don't see anything there. Example: ...
5
by: Nick Gilbert | last post by:
Hi, I recently upgraded a website from ASP.NET 1.1 to 2.0. While working on the site and changing aspx or ascx files, I sometimes randomly get a compilation error after refreshing the page in...
1
by: aspineux | last post by:
imaplib use exception to report errors, but some problems must be detected by checking the return value ! For example, when trying to append into a mailbox with wrong ACL, imaplib return 'NO',...
9
by: Alan Isaac | last post by:
I need access to 2*n random choices for two types subject to a constraint that in the end I have drawn n of each. I first tried:: def random_types(n,typelist=): types = typelist*n...
2
by: =?Utf-8?B?TWFydGluSg==?= | last post by:
I've got a web application that includes a file upload page. It was upgraded from v1.1 to 2. We haven't converted the page to use the newer file upload control, though. We're using the ...
0
by: wolfonenet | last post by:
Hi All, My setup is: WinXP Python 2.5.1 TKinter version: $Revision: 50704 $ Tcl: 8.4 Debugger: WinPdb
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.