1
I have two databases and need to ensure the persistence of the data in both in a given process.
Connection components are those of the Interbase Express package.
I did so:
database := DataModule.IBDatabase;
databaseDois := TIBDatabase.Create(nil);
try
try
transaction := database.DefaultTransaction;
transaction.StartTransaction;
databaseDois.DefaultTransaction := transaction;
databaseDois.LoginPrompt := false;
databaseDois.Params.Text := database.Params.Text
databaseDois.DatabaseName := 'databaseDois.gdb';
query := TIBQuery.Create(nil);
try
query.Database := databaseDois;
query.Transaction := transaction;
// execução dos processo no segundo banco de dados.
finally
query.Free;
end;
// execução dos processos no database original
transaction.Commit;
except
on e: exception do
begin
transaction.Rollback;
raise e;
end;
end;
finally
databaseDois.Free;
end;
What I did was create a second connection component and use the same transaction component for both. However, when trying to execute a query with the second connection an error is generated:
invalid transaction Handle (expecting Explicit transaction start)
It is possible to do this kind of control, as is, where I am missing?
Note that the transaction has already started, as shown below:
you can accept your answer (the V below the number of her votes) then it will no longer appear as unanswered.
– Caputo