RAD Studio
ContentsIndex
PreviousUpNext
Creating Additional Sessions

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

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

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!