Firebird connection problem lazarus / 16-Databases ---------------------------------------------------------------------- xinyiman · 2015-05-27 08:44 Hello guys, I have the following problem. On Linux 32-bit'm creating a server with tcp synapse. Until everything is right. But my server has to work also with firebird here and use the TibConnection. Now if I run the code once no problem, but when rieseguo the code a second time to be in error. I realized it must be linked to the CharSet TibConnection. Who explains to me how to solve? thanks Code: [Select]function TTCPEchoThrd.ApriConnessioneAlDB(var Conn: TIBConnection; var Tran: TSQLTransaction; MyHostName: string; MyDataBaseName: string; MyUserName: string; MyPassword: string; var MsgError: string): boolean; var    ret: boolean; begin        try           try             ret:=true;             //Conn.CharSet:='disabled'; //non esiste, ma almeno mi evita l'errore che mi fa saltare il db             Conn.HostName:=MyHostName;             Conn.DatabaseName:=MyDataBaseName;             Conn.UserName:=MyUserName;             Conn.Password:=MyPassword;             Conn.Transaction:=Tran;             Conn.Open;             Tran.Active:=true;             //ho ottenuto la connessione al database           finally                  //codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione          end;        except              on E: Exception do              begin                 MsgError:=E.Message;                 ret:=false;              end;        end;        result:=ret; end; ---------------------------------------------------------------------- xinyiman · 2015-05-27 10:10 The strange thing is that if I run the code from the IDE I have no problem. If you launch it from the terminal / console goes wrong. An unhandled exception occurred at $B65975F5 : EAccessViolation : Access violation   $B65975F5 ---------------------------------------------------------------------- rvk · 2015-05-27 10:56 I don't think we have enough code. Does that "unhandled exception" occur in that piece of code? (you could do some logging to see if it's really there and on what line) Where do you call ApriConnessioneAlDB and is Conn properly created? etc... etc... ---------------------------------------------------------------------- xinyiman · 2015-05-27 12:27 I think the problem is there, why comment if the piece of code there is no problem. The problem is that it is gentle enough for a project and I can not copy and paste all. If anything, if anyone is interested to help me make a support session on my pc ---------------------------------------------------------------------- taazz · 2015-05-27 14:52 Quote from: xinyiman on May 27, 2015, 12:10:26 pmThe strange thing is that if I run the code from the IDE I have no problem. If you launch it from the terminal / console goes wrong. An unhandled exception occurred at $B65975F5 : EAccessViolation : Access violation   $B65975F5 1) how do you run the code from the IDE? (opening the connection with the same paramas does not execute the code). 2) are you sure that the Conn is created when that procedure is called? Where is that object placed at design time is the container created in any way? ---------------------------------------------------------------------- xinyiman · 2015-05-28 11:22 Where the appeal procedure offending. As you can see you make the connection Code: [Select]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/d b.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.Fiel dByName('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;