Skip to content

TDatabase

Base class for connecting a FreePascal application to an external Database engine.

Declaration

Source position: db.pas line 2288

type

  TDatabase = class(TCustomConnection)
  public
    constructor Create;
    destructor Destroy;
    procedure CloseDataSets;
    procedure CloseTransactions;
    procedure StartTransaction;
    procedure EndTransaction;
    property TransactionCount: LongInt; {r}
    property Transactions[Index : LongInt]: TDBTransaction; {r}
    property Directory: string; {rw}
    property IsSQLBased: Boolean; {r}
  published
    property Connected: Boolean; {rw}
    property DatabaseName: string; {rw}
    property KeepConnection: Boolean; {rw}
    property Params: TStrings; {rw}
  end;

Description

TDatabase is a component whose purpose is to provide a connection to an external database engine, not to provide the database itself. This class provides generic methods for attachment to databases and querying their contents; the details of the actual connection are handled by database-specific components (such as SQLDb for SQL-based databases, or DBA for DBASE/FoxPro style databases).

Like TDataset, TDatabase is an abstract class. It provides methods to keep track of datasets connected to the database, and to close these datasets when the connection to the database is closed. To this end, it introduces a Connected boolean property, which indicates whether a connection to the database is established or not. The actual logic to establish a connection to a database must be implemented by descendent classes.

Properties

Member Visibility Description
Connected published Is the database connected.
DatabaseName published Database name or path.
Directory public Directory for the database.
IsSQLBased read only public Is the database SQL based.
KeepConnection published Should the connection be kept active.
Params published Connection parameters.
TransactionCount read only public Number of transaction components connected to this database.
Transactions read only public Indexed access to all transaction components connected to this database.
See all Properties

Methods

Member Visibility Description
CloseDataSets public Close all connected datasets.
CloseTransactions public End all transactions.
Create public Initialize a new TDatabase class instance.
Destroy public Remove a TDatabase instance from memory.
EndTransaction public End an active transaction.
StartTransaction public Start a new transaction.
See all Methods

See also

Name Description
TDataset Base class for records-based data-access.
TDatabase Base class for connecting a FreePascal application to an external Database engine.