Where the appeal procedure offending. As you can see you make the connection
function TTCPEchoThrd.UtenteAbilitato(NomeUtente: string; Id_Utente: string):boolean;
var
Conn: TIBConnection;
Tran: TSQLTransaction;
Query: TSQLQuery;
ErrMes: string;
ret: boolean;
begin
try
try
Conn:=TIBConnection.Create(nil);
Tran:=TSQLTransaction.Create(nil);
if (Self.ApriConnessioneAlDB(Conn,Tran,'127.0.0.1','/DB/db.fdb','user','pwd',ErrMes)=true) then
begin
ret:=false;
Self.CredenzialiOK:=false;
Self.Log(' CONNESSIONE AL DB EFFETTUATA');
Query:=TSQLQuery.Create(nil);
Query.DataBase:=Conn;
Query.SQL.Text:='select PATH from T_User WHERE ID=:Id and Nome=:User';
Query.Params.ParamByName('Id').AsInteger := StrToInt(Id_Utente);
Query.Params.ParamByName('User').AsString := NomeUtente;
Query.Open;
if not Query.EOF then
begin
Query.First;
Self.DataBaseDellUtenteRemoto:=Trim(Query.FieldByName('PATH').AsString);
if ((Length(Self.DataBaseDellUtenteRemoto)>0) and (FileExists(Self.DataBaseDellUtenteRemoto))) then
begin
ret:=true;
Self.CredenzialiOK:=true;
end;
end;
Query.Close;
Query.Free;
Self.ChiudiConnessioneAlDB(Conn,Tran,ErrMes);
Self.Log(' CONNESSIONE AL DB CHIUSA');
end
else
begin
Self.Log('ERRORE ' + ErrMes);
end;
finally
//codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione
Tran.Free;
Conn.Free;
end;
except
on E: Exception do
begin
ret:=false;
Self.Log('ERRORE ' + E.Message);
end;
end;
result:=ret;
end;