Invalid connection in the connection pool

  • Thread starter Thread starter Graham Allwood
  • Start date Start date
G

Graham Allwood

Hi,

does anyone know how I can determine if a connection in the connection pool
has become invalid?

The problem I have is that I'm hosting some remote components in IIS and
these components use ADO.NET to connected to SqlServer. Now, connection
pooling is enabled so if the backend Sql database goes down for a short
while and then comes back up, all connections in the pool are now invalid
and the next time I try and use one I get an exception. I need to be able to
distinguish this from a real database problem and an invalid poolled
connection.

does anyone have any ideas?


Thanks for any help

Graham
 
Hi Graham,

You can't.
However, the first time you try to use invalid connection ado.net will
understand that it is invalid and it will remove it from pool.
Or, when you get an exception on connection, try using the same connection
string+ one whitespace at the end - that will trigger new connecition ...
 
Thanks for that, but is that the only way? Is there any way I could
distinguish the exception being thrown as one that is caused by an invalid
pooled connection?
 
Back
Top