Page 1 of 1

Error while closing form with TZConnection.Connected=False

Posted: 20.03.2008, 09:05
by dayat
Hi, I was edited this code for my problem in home. See the code below, I replace:

function TZConnection.GetInTransaction: Boolean;
begin
CheckConnected;
Result := not FAutoCommit or (FExplicitTransactionCounter > 0);
end;

with:

function TZConnection.GetInTransaction: Boolean;
begin
try
CheckConnected;
except
Result:=False;
Exit;
end;
Result := not FAutoCommit or (FExplicitTransactionCounter > 0);
end;

I've the story with this problem :shock: . Sometime my application fail when connect to database, application still running, but property of Connected=False. When I closing the application, method of CheckConnected raising the error, and my application can't close :cry: , I must terminated with task manager :twisted: , or write code Application.Terminate.

You can try for get the error message with fail login, such enter the wrong of user name or password, until the main form showing. And then try close the main form, the moment a method GetInTransaction executing method CheckConnected and raising the error.

I use postgresql-8.1, Turbo Delphi and 6.6.2-RC version of Zeos.

:idea: Or you have other solution, my be any code must be edited, but not this code.

Thanks
dayat