Creating Additional Sessions

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.

You can create sessions to supplement the default session. At design time, you can place additional sessions on a data module (or form), set their properties in the Object Inspector, write event handlers for them, and write code that calls their methods. You can also create sessions, set their properties, and call their methods at run time.

Note: Creating additional sessions is optional, unless an application runs concurrent queries against a database or the application is multithreaded.

To enable dynamic creation of a session component at run time

  1. Declare a TSession variable.
  2. Instantiate a new session by calling the Create method. The constructor sets up an empty list of database components for the session, sets the KeepConnections property to True, and adds the session to the list of sessions maintained by the application's session list component.
  3. Set the SessionName property for the new session to a unique name. This property is used to associate database components with the session. For more information about the SessionName property, see Naming a Session.
  4. Activate the session and optionally adjust its properties.

You can also create and open sessions using the OpenSession method of TSessionList. Using OpenSession is safer than calling Create, because OpenSession only creates a session if it does not already exist. For information about OpenSession, see Managing Multiple Sessions.

See Also