Error: Invalid operation in non AutoCommit mode
Posted: 02.03.2011, 02:18
Hi there everyone,
I am using the code below to manage transactions in my application.
What I find odd is that I get an error "invalid operation in non AutoCommit mode" everytime I try to update the database. I later discovered that the error is due to the line
Once I comment out this line, everything works fine.
Is this normal? Why should the explicit call to "StartTransaction" on a Zeos connection generate an error? Does setting "AutoCommit := False" implicitly start a transaction? Is it one or the other but not the two at the same time?
Thanks for your assistance.
JD
I am using the code below to manage transactions in my application.
Code: Select all
procedure TForm1.DoTransaction(DataSet: TDataSet);
begin
with ZConnection1 do
begin
if not AutoCommit then
begin
StartTransaction; //Gives me an error 'invalid operation in non AutoCommit mode'
try
Commit;
except
Rollback;
end;
Dataset.Refresh;
end;
end;
end;
Code: Select all
StartTransaction
Is this normal? Why should the explicit call to "StartTransaction" on a Zeos connection generate an error? Does setting "AutoCommit := False" implicitly start a transaction? Is it one or the other but not the two at the same time?
Thanks for your assistance.
JD