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!
Get the behavoir of the Delphi IB compos
-
AndreyZ
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!
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
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:If you add the following code:, 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: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.
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 serverCode: Select all
IBTable.Transaction.Commit;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');