Icon Opening Databases

As already discussed in the ElevateDB Architecture topic, the TEDBDatabase component represents a database in ElevateDB. The following information will show how to open a database in an application.

Preparing a Database for Opening
Before you can open a database using the TEDBDatabase component, you must set a couple of properties. The TEDBDatabase DatabaseName property is the name given to the database within the application and is required for naming purposes only. The Database property should contain the name of an existing database that has already been created using a CREATE DATABASE DDL statement.

Opening a Database
To open a database you must set the TEDBDatabase Connected property to True or call its Open method. For a local TEDBDatabase component whose SessionName property is linked to a local TEDBSession component, the database will cause the local TEDBSession to be opened if it is not already, and then the database will be opened. For a remote database whose SessionName property is linked to a remote TEDBSession component, performing this operation will cause the remote session to attempt a connection to the ElevateDB Server if it is not already connected. If the connection is successful, the database will then be opened.

The BeforeConnect event is useful for handling the setting of any pertinent properties for the TEDBDatabase component before it is opened. This event is triggered right before the database is opened, so it's useful for situations where you need to change the database information from that which was used at design-time to something that is valid for the environment in which the application is now running.

Information You should not call the TEDBDatabase Open method or modify the Connected property from within the BeforeConnect event handler. Doing so can cause infinite recursion.

More Database Properties
A TEDBDatabase component has one other property of importance that is detailed below:

PropertyDescription
KeepConnectionControls whether the database connection is kept active even after it is no longer needed. This property has no effect upon a local session, but can result in tremendous performance improvements for a remote session, therefore it defaults to True and should be left as such in most cases.
Image