I open a connection like this:
Using conn as New OdbcConnection(connectionString) conn.Open() //do stuff End Using
If connection pooling is enabled, the connection is not physically closed but released to the pool and will get reused. If it is disabled, it will be physically closed.
Is there any way of knowing programmatically if connection pooling is enabled or not? and the number of used and unused connections currently open in the pool?
EDIT: I need to get this information from within the program, I can’t go and check it manually on every single PC where the program will be deployed.
Looks like you can just read this registry key:
[HKEYLOCALMACHINE]\SOFTWARE\ODBC\ODBCINST.INI\SQL Server\CPTimeout
(or some variant thereof, depending on your OS and user account). If the value is 0, then connection pooling is disabled. If it’s any value above 0, it’s enabled.
See:
http://msdn.microsoft.com/en-us/library/ms810829.aspx
I’m not sure about getting the number of open connections. Just curious: why do you need to know the number?