[Q] Connection lost during post
Posted: 18.10.2016, 13:05
just want to to know how to properly handle that situation when there is connection error during applyupdates call, I thought that i can catch error reconnect and apply updates again but reconnect will close all datasets
Edit:
I can create helper to prevent dataset closing
i can make it works but when next Connection.Disconnect is called during program shutdown im getting errors like Disconnect, Error: Error reading data from the connection., Code: -902 (Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements)
Edit:
I can create helper to prevent dataset closing
Code: Select all
procedure TZConnectionHelper.ForceReconnect;
begin
if FConnection <> nil then
begin
DoBeforeReconnect;
ShowSqlHourGlass;
try
try
FConnection.Close;
except
Rollback; // decrement transaction count
end;
FConnection.Open;
finally
HideSqlHourGlass;
end;
DoAfterReconnect;
end;
end;
with bellow changes in unit ZDbcInterbase6
procedure TZInterbase6Connection.Close;
begin
if Closed or (not Assigned(PlainDriver)) then
Exit;
try
try
CloseTransaction;
except
end;
if FHandle <> 0 then
begin
GetPlainDriver.isc_detach_database(@FStatusVector, @FHandle);
FHandle := 0;
CheckInterbase6Error(GetPlainDriver, FStatusVector, ConSettings, lcDisconnect);
end;
finally
DriverManager.LogMessage(lcConnect, ConSettings^.Protocol,
'DISCONNECT FROM "'+ConSettings^.DataBase+'"');
inherited Close;
end;
end;