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 runtime.
Note: Creating additional sessions is optional unless an application runs concurrent queries against a database or the application is multi-threaded.
To enable dynamic creation of a session component at runtime
- Declare a TSession variable.
- 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.
- 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.
- 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..