Naming a Session

From RAD Studio
Jump to: navigation, search

Go Up to Managing database sessions 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.

A session's SessionName property is used to name the session so that you can associate databases and datasets with it. For the default session, SessionName is "Default". For each additional session component you create, you must set its SessionName property to a unique value.

Database and dataset components have SessionName properties that correspond to the SessionName property of a session component. If you leave the SessionName property blank for a database or dataset component it is automatically associated with the default session. You can also set SessionName for a database or dataset component to a name that corresponds to the SessionName of a session component you create.

The following code uses the OpenSession method of the default TSessionList component, Sessions, to open a new session component, set its SessionName to "InterBaseSession," activate the session, and associate an existing database component, Database1, with that session:

var
  IBSession: TSession;
  ...
begin
  IBSession := Sessions.OpenSession('InterBaseSession');
  Database1.SessionName := 'InterBaseSession';
end;
TSession *IBSession = Sessions->OpenSession("InterBaseSession");
Database1->SessionName = "InterBaseSession";

For more information about using Sessions, see Managing Multiple Sessions.

See Also