Get the behavoir of the Delphi IB compos

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
GVCL
Posts: 17
Joined: Tue 09 Dec 2008 16:08

Get the behavoir of the Delphi IB compos

Post by GVCL » Thu 07 Jul 2011 11:55

Hi,

I am sure, I read it somewhere but can not find it...

How can I get exactly the behavior of the Delphi IB/BDE comps with IBDAC? I especially mean the transaction behavior.

I have to update an app and found that just changing the comps does not lead to the wanted result. The standard/default property settings of the IBDAC table and query comps cause a quite different result. Probably this is well know - but I could not get the app/comps to behave as they did before.

Any hint?

Thank you for any idea!

AndreyZ

Post by AndreyZ » Fri 08 Jul 2011 10:41

Hello,

Transaction behaviour in IBDAC is similar to the one in the standard IB components by default. Please specify the exact situation and the transaction behaviour in this situation you want to get with IBDAC.

GVCL
Posts: 17
Joined: Tue 09 Dec 2008 16:08

Post by GVCL » Thu 14 Jul 2011 17:14

Hi Andrey,

sorry for the delay...

Delphis IB comps have not to be reopened, when I post a record e.g. They immediately show the 'refreshed' recordset (TIBTable). I can start a transaction any time and all datasets are included and a commit does not close the datasets. With IBDAC - it seems - I have to reopen all datasets after a commit.

I want to update single tables without starting a transaction explicitly and without reopen the table. And I want to start a transaction any time, do updates or what ever and then commit or rollback without having to reopen the datasets. This is exactly what the app does with the Delphi IB comps.

How can I achieve this with IBDAC?

Any hint is appreciated!

Thank you!

AndreyZ

Post by AndreyZ » Fri 15 Jul 2011 11:32

The point is that the standard IB components do not commit changes by default. For example, the following code doesn't send edited data to the server:

Code: Select all

IBTable.TableName := 'tablename';
IBTable.Open;
IBTable.Edit;
IBTable.FieldByName('stringfield').AsString := 'test';
IBTable.Post; // here no data will be sent to the server
If you add the following code:

Code: Select all

IBTable.Transaction.Commit;
, data will be sent to the server and IBTable will be closed.
IBDAC transaction behaviour differs from the standard one. IBDAC components commit changes immediately after changes were made. Also, to avoid dataset closing, IBDAC calls the CommitRetaining method instead of Commit. That's why dataset will not be closed after posting changes. The following example demonstrates the difference between IB components and IBDAC components:

Code: Select all

IBCTable.TableName := 'tablename';
IBCTable.Open;
IBCTable.Edit;
IBCTable.FieldByName('stringfield').AsString := 'test';
IBCTable.Post; // here data will be sent to the server
if IBCTable.Active then // IBCTable will remain active
  ShowMessage('active');
To get the same transaction behaviour with IBDAC as with IB, you can set the TIBCConnection.AutoCommit property to False and the TIBCConnection.DefaultTransaction.DefaultCloseAction property to taCommit. In this case IBDAC components will not commit changes automatically, and you will be able to manage transactions on your own.

GVCL
Posts: 17
Joined: Tue 09 Dec 2008 16:08

Post by GVCL » Mon 18 Jul 2011 15:09

Hi Andrey,

thank you - that made it clear!

I will see if the app works as before when changing from IB to IBDAC and using the settings you mentioned.

Post Reply