[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'db' (#fcl)

# TDatabase

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

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

## Declaration

Source position: db.pas line 1927

`type TDatabase = class(TCustomConnection)`
`public`
`constructor Create(); override;` |  | Initialize a new TDatabase class instance.
`destructor Destroy; override;` |  | Remove a TDatabase instance from memory.
`procedure CloseDataSets;` |  | Close all connected datasets
`procedure CloseTransactions;` |  | End all transactions
`procedure StartTransaction; virtual; abstract;` |  | Start a new transaction.
`procedure EndTransaction; virtual; abstract;` |  | End an active transaction.
`property TransactionCount: LongInt; [r]` |  | Number of transaction components connected to this database.
`property Transactions: TDBTransaction; [r]` |  | Indexed access to all transaction components connected to this database.
`property Directory: string; [rw]` |  | Directory for the database
`property IsSQLBased: Boolean; [r]` |  | Is the database SQL based.
`published`
`property Connected: Boolean; [rw]` |  | Is the datbase connected
`property DatabaseName: string; [rw]` |  | Database name or path
`property KeepConnection: Boolean; [rw]` |  | Should the connection be kept active
`property Params: TStrings; [rw]` |  | Connection parameters
`end;`

## Inheritance

`TDatabase` |  | Base class for connecting a FreePascal application to an external Database engine
`TCustomConnection` |  | Abstract class for connections to a server
`TComponent,IUnknown,IInterfaceComponentReference`
`TPersistent,IFPObserved`
`TObject`

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

## See also

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

Documentation generated on: Feb 26 2014