Class TDAODatabase (unit DAODatabase)

Inherits from

TComponent

TDAODatabase provides control over a connection to single database in a database application.
Use TDAODatabase when a database application requires any of the following control over a database connection:

  1. Persistent database connections
  2. Customized database logins
  3. Transaction control

Note

You may use original DAO Database and Workspace objects through _Database and _Workspace interfaces, which are declared in public section of TDAODatabase.

Functions


procedure BeginTrans;

Opens new transaction.


procedure Close;

Closes a dataset.

Call Close to set the Active property of a dataset to False. When Active is False, the dataset is closed; the dataset cannot read data from or write data to the database.


procedure CommitTrans;

CommitTrans finishes current transaction and keeps changes.


procedure Execute(SQL: string);

Executes the SQL statement.

Call Execute to execute the INSERT, UPDATE, or DELETE statement without parameters.


procedure GetQueryDefNames(List: TStrings);

Populates a string list with the names of QueryDefs associated with a specified database.


procedure GetTableIndexes(TableName: string; List: TStrings);

Populates a string list with the names of Indexes associated with a specified table.


procedure GetTableNames(List: TStrings);

Populates a string list with the names of TableDefs associated with a specified database.


procedure Open;

Connects to a database.

Call Open to establish a connection to a database, specified by the DatabaseName property.
Setting Connected to True also connects to the database.


procedure Rollback;

Cancels all changes for the current transaction and ends the transaction.


Properties


property Connected : Boolean

Indicates whether or not a database connection is active.

Set Connected to True to establish a database connection without opening a dataset.
Set Connected to False to close a database connection. An application can check Connected to determine the current status of a database connection.


property CreateWorkspace : Boolean

Set CreateWorkspace to True when you need to create Workspace object.
Workspace is necessary for work with Access user security.


property DatabaseName : string

Expression specifying a name of an existing file of a database.


property Exclusive : Boolean

Defines a type of access to a database.

Set Exclusive to True to define an exclusive access to a database.
Set Exclusive to False for common access.


property Password : string

Use Password to specify password of the protected database.

Note

It is the password of a database, instead of user.


property ReadOnly : Boolean

Set ReadOnly to True if the database opens only for reading.


property Workspace : TWorkspace

Workspace provides properties, which are necessary for work with secured databases.


property Datasets : TList

Provides an indexed array of all active datasets for a database component.

Use DataSets to access active datasets associated with a database component. An active dataset is one that is currently open.


property RecordsAffected : Integer

Returns number of records, which were used by last call of a method Execute.

The returned value lays in an interval from 0 up to number of records, which were used by last call of method Execute for TDAODatabase.


Variables


_Database : Database;

Provides interface to native DAO Database object.


_Workspace : Workspace;

Provides interface to native DAO Workspace object.

Note

You may use interface to Workspace only when CreateWorkspace is True.