Hi All,
with this code, I use Firebird embedded for my application leaving server blank:
with ServerConn do
begin
if(Connected) then Disconnect;
ProviderName:=ConnIni.ReadString('fbconnection','ProviderName','');
// server:=ConnIni.ReadString('fbconnection','server','');
// port := ConnIni.ReadInteger('fbconnection','port',0);
password:='masterkey';
username:='SYSDBA';
Database:=ExtractFilePath(Application.ExeName)+'Data\'+ConnIni.ReadString('fbconnection','database','');
SpecificOptions.Values['ClientLibrary'] := 'fbclient.dll';
end;
ServerConn.Connect;
In this way, I use a local database.
I have problems with this code:
with aq do
begin
edit;
FieldByName('eurocoworking').AsFloat:=euroCow;
FieldByName('Numgiorni').AsFloat:=NumGiorni;
FieldByName('PerceCoworking').AsFloat:=perceCOw;
FieldByName('eurocoworking').AsFloat:=euroCow;
FieldByName('costozero').AsFloat:=COstozero;
FieldByName('percericarico').AsFloat:=perceRic;
FieldByName('imporicarico').AsFloat:=Imporicarico;
FieldByName('costoalcliente').AsFloat:=costoAlCLiente;
try
begin
Connection.StartTransaction;
post;
Connection.Commit;
end;
except on E: Exception do
begin
if(Connection.InTransaction) then
Connection.Rollback;
end;
end;
end;
On connection.starttransaction I have an exception: Can't perform operation on active transaction.
With Firebird embedded, I don't need transaction?
Can you help me?
Thanks, Flavio
Firebird Embedded
Re: Firebird Embedded
Hi,
As I remember, when you connect to FireBird the transaction is started automatically. Read documentation and the posts on this forum.
Regards
Michal
As I remember, when you connect to FireBird the transaction is started automatically. Read documentation and the posts on this forum.
Regards
Michal
-
- Posts: 44
- Joined: Wed 14 Nov 2012 17:33
Re: Firebird Embedded
This means that if I have an application and I would like to have the same code for MySQL e Firebird, I need to rewrite many parts of my code? It isn't possible only change the Provider?
Re: Firebird Embedded
Hi,
Probably you should make some exceptions in your code, but I'm not working with FireBird. The programmers from DevArt can give you more detailed answer.
Read the posts on this forum. This subject was described here many times.
Michal
Probably you should make some exceptions in your code, but I'm not working with FireBird. The programmers from DevArt can give you more detailed answer.
Read the posts on this forum. This subject was described here many times.
Michal
Re: Firebird Embedded
InterBase/Firebird requires an active transaction for any operation with data, even for opening dataset. Therefore, when calling TUniQuery.Open, it is verified if a transaction associated with it is running and, if it is not so - it is automatically run. In your example dataset uses a default transaction TUniConnection, therefore when attempting to call the Connection.StartTransaction method in your example, you get the "Can't perform operation on active transaction" error, because when opening dataset the transaction has already started.
To solve the issue you can use the following advice:
- use for dataset a separate transaction, not a default transaction TUniConnection;
- use for data modification UpdateTransaction.
You can get more information about working with transactions when connecting to Firebird on our forum:
viewtopic.php?f=28&t=25591
viewtopic.php?f=28&t=32310
viewtopic.php?f=24&t=25421
To solve the issue you can use the following advice:
- use for dataset a separate transaction, not a default transaction TUniConnection;
- use for data modification UpdateTransaction.
You can get more information about working with transactions when connecting to Firebird on our forum:
viewtopic.php?f=28&t=25591
viewtopic.php?f=28&t=32310
viewtopic.php?f=24&t=25421
Re: Firebird Embedded
Not so UNI now is it..isysoftware wrote:This means that if I have an application and I would like to have the same code for MySQL e Firebird, I need to rewrite many parts of my code? It isn't possible only change the Provider?
I solved this issue with a Class Helper, Commit and Rollback (not shown) all redirect to their respective Retaining calls for FB.
If you want strict transaction handling in FB then turn off AutoCommit:
Code: Select all
procedure TUniConnection.StartTransaction(const TurnAutoCommitOFF: boolean = false);
begin
case dbProvider of
dbFirebird: begin
if TurnAutoCommitOFF then AutoCommit := false;
if AutoCommit then Exit;
if InTransaction then inherited CommitRetaining
else inherited StartTransaction;
end;
else inherited StartTransaction;
end;
end;