ZConnection is the connection between the database and the individual database components. The TZConnection component is similar to the Delphi BDE TDatabase. Zeos is very similar to the BDE components in the function.


AutoCommit is true by default. This controls the so-called transactions. The Firebird database does not write the changed, deleted or newly created data directly (physically) to the database immediately. The data is buffered and only when the SQL Commit command is issued will the data be written to the storage medium. If an error occurs, all data processed from the beginning of the transaction will be discarded. The principle is that either all changes are OK or the original state is restored.
AutoCommit True means that in the event of a change, deletion or reinvestment, the data is written immediately (= confirmed with commit). This corresponds to the behavior of the BDE components of Delphi.

In order to get the "sovereignty" over a transaction itself, in order to summarize several SQL commands the method StartTransaction must be called. AutoCommit is then switched off. Calling the Commit method confirms the changes or writes them to the data store. 'The Rollback method can be used to undo these changes since starting with StartTransaction. After completing this one transaction, AutoCommit will turn back on.

The explanation of transactions

If AutoEncodeStrings is active, Zeos will try to translate your data between the connection set and the ControlsCodePage setting. This can lead to data loss if a conversion is not possible. AutoEncodeStrings should therefore only be set to true if conversion is really necessary.

Not used by Firebird. It is intended for PostgreSQL.

This is the character set that our program requests from the database server to send the data to our program. Most servers can easily convert characters between the requesting program and the server. In a Unicode development system like Lazarus, it is best to request character data in UTF8.

Connected connects the database to our program if the value is set to true. If false, the connection is broken.

It lets you determine which character encoding you prefer in your TDatasets (TZQuery, TZReadOnlyQuery, and TZTable).

cCP_UTF8: This is the default for Lazarus. The passed strings are expected as UTF8 and the TStringFields are passed. Since TStringField also provides only one byte for multibyte characters, Zeos increases the size of TStringField fourfold. A VarChar 10-character string has a TSTringField.Size size of 40 characters.

cCP_UTF16 and cGET_ACP: are implemented because Delphi and should not be used in Zeos.

The location and name of the database ending with ".fdb",

If set to true, the design-time connection is active and the database controls (ZQuery, ...) in the forms can be edited. Did not work for me with Firebird.

Host Name:
Can usually be left blank for our purposes. It may be necessary to enter "localhost" or the IP address of the database here.

Library Location:
Where the database program fbclient.dll is located during the default installation
for example, "C: \ Program Files \ Firebird \ Firebird_4_0 \ fbclient.dll".

If true, the user and password are asked.

The name of the component, default is ZConnection1.

The default password of Firebird is "masterkey".

If there are problems with the database, the default value "3050" of the Firebird database may help. For multiple Firebird installations, you can specify the port number, e.g. set to 3051.

In our case it will be used in the program and issue the create command. Various parameters can be passed to the database here.

In our case always "firebird".

Read Only:
If the value is set to true, the data can only be queried but not edited.

Shows an "hourglass" while a SQL statement is being executed.

Standard of Lazarus for all components. I can not think of using this component.


tiNone: is not supported by Firebird and acknowledged with an error message

tiRepeatableRead: This is equivalent to the Transaction Isolation Lever (TIL) "Snapshot" from Firebird and is standard on Firebird. A "snapshot" of the used dataset will be created, but other users will get an error message if two transactions want to edit the same dataset, changes of other transactions will not be noticed.

tiReadCommitted: The setting we use. This setting is Firebird's TIL "Read Committed". This setting honors the changes made by other users to Commit. With the parameter "rec_version" always the changes stored by other users are perceived. Another parameter, "Nowait", ensures that you do not wait for the release of blocked records. Firebird is more stressed with this setting.

tiSerializable: Provides exclusive access to the data to be edited and prevents multi-user access.

If true, then metadata (system tables) will be used.

The username of the database. Default or start username of Firebird

The version of Zeos components.


The events of ZConnection
Are actually self-explanatory. It is possible to insert your own program code before or after the operation of TZConnection. The insertion of own program parts is to be handled as with all other Lazarus components.

Own program code can be executed when:

AfterConnect: After connecting to the database
AfterDisconnect: After terminating the database connection
AfterReconnect: After another connection to the database
BeforeConnect: Before the database is connected to the program
BeforeDisconnect: Before the connection is finally interrupted
BeforeReconnect: Before further connecting to the database
OnCommit: When a commit (data is written) is issued
OnLogin: When logging into the database
OnRollback: When a rollback (changes are discarded) is made
OnStartTransaction: When a new transaction is started



© CMBasic.de