Understanding Database and Session Component Interactions

From RAD Studio
Jump to: navigation, search

Go Up to Connecting to databases with TDatabase Index

Note: 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.

In general, session component properties provide global, default behaviors that apply to all implicit database components created at run time. For example, the controlling session's KeepConnections property determines whether a database connection is maintained even if its associated datasets are closed (the default), or if the connections are dropped when all its datasets are closed. Similarly, the default Bde.DBTables.TSession.OnPassword event for a session guarantees that when an application attempts to attach to a database on a server that requires a password, it displays a standard password prompt dialog box.

Session methods apply somewhat differently. Bde.DBTables.TSession methods affect all database components, regardless of whether they are explicitly created or instantiated implicitly by a dataset. For example, the session method DropConnections closes all datasets belonging to a session's database components, and then drops all database connections, even if the KeepConnection property for individual database components is True.

Database component methods apply only to the datasets associated with a given database component. For example, suppose the database component Database1 is associated with the default session. Database1.CloseDataSets() closes only those datasets associated with Database1. Open datasets belonging to other database components within the default session remain open.

See Also