views:

32

answers:

1

Hi there,

I am using Microsoft Enterprise Library for MS SQL. Enterprise Library automatically closes its connection, but I don't want it to close. How can I keep open an Enterprise Library Connection?

Thanks a lot..

A: 

Actually, it doesn't work that way. The .NET level DbConnection will open and close, yes. But down the the ADO.NET driver, the physical connection to the database (the one that actually requires client & server resources) doesn't get opened and closed for each one. The ADO.NET driver manages a pool of physical connections. So each one of those 52000 connections is actually sharing the same physical underlying connection. It's not really costing you anything.

The connection management is actually about 50% of the reason the Data Access block exists, so there's no easy switch to turn it off. The best you can do would be to create the DbConnection manually and pass it to the overloads that take a connection. But then you need to manage it yourself. At that point you're probably better off just calling ADO.NET directly.

Chris Tavares