TADOConnection.Close - 连接在 MS-SQL 服务器上仍然有效
TADOConnection.Close - connection still active on MS-SQL server
我有几个 Delphi 程序 (XE3),它们使用 TADOConnection 连接到 MS-SQL 服务器。
我最近检查了 "MS SQL Server Management Studio" 进程列表中的连接。
- 程序启动时,连接处于非活动状态,没有连接
服务器的进程列表。
- 当我打开连接时,它显示在进程列表中 - 如
预期。
- 当我关闭连接时(肯定是 属性 "Connected"
returns FALSE),连接仍显示在服务器进程上
列表。
在我关闭程序之前,服务器上的连接不会关闭。
有没有办法在不退出程序的情况下以真正删除服务器上的连接的方式关闭 TADOConnection?
这是连接池;是一件好事。
但如果您真的想影响性能,您可以通过将请求添加到连接字符串来选择退出连接池功能:
Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;
User ID=myUsername;Password=correct horse battery stapler;OLE DB Services=-2;
这些 OLE DB Services
选项记录在 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
我有几个 Delphi 程序 (XE3),它们使用 TADOConnection 连接到 MS-SQL 服务器。 我最近检查了 "MS SQL Server Management Studio" 进程列表中的连接。
- 程序启动时,连接处于非活动状态,没有连接 服务器的进程列表。
- 当我打开连接时,它显示在进程列表中 - 如 预期。
- 当我关闭连接时(肯定是 属性 "Connected" returns FALSE),连接仍显示在服务器进程上 列表。
在我关闭程序之前,服务器上的连接不会关闭。
有没有办法在不退出程序的情况下以真正删除服务器上的连接的方式关闭 TADOConnection?
这是连接池;是一件好事。
但如果您真的想影响性能,您可以通过将请求添加到连接字符串来选择退出连接池功能:
Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;
User ID=myUsername;Password=correct horse battery stapler;OLE DB Services=-2;
这些 OLE DB Services
选项记录在 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