Otis wrote:
When connection pooling is used (and normally this is the case with ADO.NET), creating a full, open connection is 20ms or less. .
You could pass along an adapter object to your controls, and by creating teh adapter, set the KeepConnectionOpen flag to true. This means that actions performed by the controls using the adapter will not open and close the connection but will keep it open.
Actually, after thinking about it a little, I wouldn't open it on begin_request but might implement some type of Singleton pattern to manage it. If it hasn't been created yet, then create it. If it has already been created and opened, then serve it back to the requestor. Then have some code in a couple different places (end_request, on_error, etc.) to clean up any open connections.
I agree with the 20ms statement but have seen where using one open connection for a recursive call versus opening it each time, can save a fair amount of time. I will experiment with the above approach.
Follow-up question: Do connections time out or clean up on their own?