Specifying Default Database Connection Behavior

From RAD Studio
Jump to: navigation, search

Go Up to Managing database sessions Index

Attention: The Borland Database Engine (BDE) has been deprecated, so it will not be enhanced. For instance, BDE will never have Unicode support. You should not undertake new development with BDE. Consider migrating your existing database applications from BDE to dbExpress.

KeepConnections provides the default value for the KeepConnection property of implicit database components created at run time. KeepConnection specifies what happens to a database connection established for a database component when all its datasets are closed. If True (the default), a constant, or persistent, database connection is maintained even if no dataset is active. If False, a database connection is dropped as soon as all its datasets are closed.

Note: Connection persistence for a database component you explicitly place in a data module or form is controlled by that database component's KeepConnection property. If set differently, KeepConnection for a database component always overrides the KeepConnections property of the session. For more information about controlling individual database connections within a session, see Managing Database Connections.

KeepConnections should be set to True for applications that frequently open and close all datasets associated with a database on a remote server. This setting reduces network traffic and speeds data access because it means that a connection need only be opened and closed once during the lifetime of the session. Otherwise, every time the application closes or reestablishes a connection, it incurs the overhead of attaching and detaching the database.

Note: Even when KeepConnections is True for a session, you can close and free inactive database connections for all implicit database components by calling the DropConnections method. For more information about DropConnections, see Dropping Inactive Database Connections.

See Also