Hey, I've just discovered this nifty new method called ClearPool and its little sister ClearPools, that allow you the clean out the connection pool, either for a single connection string, or for all connection strings.
Why would you want a method like this?
Well, sometimes I've done this little demo to illustrate the connection-lessness of DataSets, where I load the data from a database into a dataset, and then I shut down the database while keeping my application running. Then I restart the database and then send my changes made with the application back to the database. However, if connection pooling is turned on I would get this SqlException, because the connection in the pool has become invalid.
So, easy, you might think. Simply retry to get a new connection. If, however, your application has a couple of other connections in the connection pool this scenario is going to repeat itself, until you clear out the connection pool and get a new one. With this method this is going to be a lot simpler! Got the exception? ClearPool, then retry.