0

I have several Delphi programs (XE3), that use a TADOConnection to connect to a MS-SQL Server. I recently checked the connections in the "MS SQL Server Management Studio"'s process list.

  • When the program starts, the connection is inactive, no connection in the server's process list.
  • When I open the connection it's shown in the process list - as expected.
  • When I close the connection (definitely the property "Connected" returns FALSE), the connection is still shown on the servers process list.

On the server the Connection is not closed until I close the program.

Is there a way to close the TADOConnection in a way that really removes the connection on the server without exiting the program?

1
  • 2
    Looks like normal connection pooling behavior. I would expect the physical connection to be closed after a couple of minutes of inactivity. Commented Feb 9, 2018 at 12:41

2 Answers 2

2

This is connection pooling; and is a good thing.

But if you really want to hurt performance, you can opt-out of connection pooling features by adding the request to your connection string:

Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase; User ID=myUsername;Password=correct horse battery stapler;OLE DB Services=-2; 

These OLE DB Services options are documented on MSDN:

Pooling in the Microsoft Data Access Components (archive)

OLE DB Services Services enabled =============== ================================================== -1 All services (the default) -2 All services except pooling -4 All services except pooling and auto-enlistment -5 All services except client cursor -6 All services except client cursor and pooling 0 No services 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot for the enlightenment! Now I know, that I can just ignore those as they are not reason to poor programming.
0

The connection will close if you have closed all the objects using the connection before you try to close the connection itself.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.