Connecting m$ access Database via ODBC in linux lazarus / 1-Linux ---------------------------------------------------------------------- jluix · 2007-03-11 19:11 Hi! This link is a copy of the first one I put into databases forum, but is possible its correct place it's here: I've been working with Lazarus under Windows the last two years, and now I'm starting to work in linux (ubuntu 6.10) so, I want to re- compile all my proyects to this new O.S. My problem is that I don't know how to link via ODBC with databases (the proyect I want to migrate now is linked to M$ Access database). The first I did was to install unixODBC and mdbtools package (that comes with and Access ODBC called libmdbodbc.so.0). Then I wrote /etc/odbcinst.ini as I saw in a web with: [Microsoft Access Driver (*.mdb)] Description = MDB Tools ODBC drivers Driver = /usr/lib/libmdbodbc.so.0 Setup = FileUsage = 2 CPTimeout = CPReuse = and the /etc/odbc.ini with: [Cofinanza] Description = Base de datos de Cofinanza Driver = Microsoft Access Driver (*.mdb) Database = /home/jluix/Proyectos_Lazarus/Cofinanza/Cofinanza.mdb Servername = localhost Obviously, Cofinanza.mdb is the database I want to access. In ODBCConfig I can see now the result of previous sentences but, when I try run my program with the next lines (that work fine in windows): ODBC.Driver:='Microsoft Access Driver (*.mdb)'; ODBC.Params.Add('DBQ='+Param1); ODBC.Params.Add('PWD='+Param2) ..... ODBC.Connected:=True; I got an error message: Project raised exception class 'EInOutError' with message: Can not load ODBC client. Is it installed? (libodbc.so). I've been browsing a lot for the solution but I'ven't got luck. Could you help me?. Many thanks. ---------------------------------------------------------------------- Marc · 2007-03-12 16:26 Is libodbc.so installed ?? IOW, do you have a libodbc.so somewhere in your lib dir ? ---------------------------------------------------------------------- jluix · 2007-03-12 17:53 Well... First: Thanks for the reply! Second: At last, I could to link mdb ODBC with unixODBC renaming (create a ln) libodbc.so.0 to libodbc.so (using DataManager I checked the conexion). After that, I tried to use this odbc conexion in my program through the controls           ODBC : tODBCConnection;           SQLQ : tSQLQuery;           SQLT : tSQLTransaction; and the sentences           ODBC.FileDSN:='/etc/odbc.ini';           ODBC.DatabaseName:='Cofinanza';           ODBC.Password:=Param2;          ODBC.Connected:=false;          ODBC.Transaction:=SQLT;          SQLT.Active:=False;          SQLT.DataBase:=ODBC;          SQLQ.Active:=False;          SQLQ.DataBase:=ODBC;          SQLQ.Transaction:=SQLT; ------------------------------------------------ function tBDSQL.EjecutaSQL(Comando : string) : boolean; var    Ejecutado : boolean;    EsSelect : boolean;    StrAux : string; begin      //Se comprueba si la orden es un select, pues la ejecución varía      StrAux:=UpperCase(Copy(Trim(Comando),1,6));      if StrAux='SELECT' then EsSelect:=True else EsSelect:=False;      if SQLQ.Active then SQLQ.Close;      try         SQLQ.SQL.Clear;         SQLQ.SQL.Add(Comando);         if EsSelect then           SQLQ.Open         else begin           SQLQ.ExecSQL;           end;         Ejecutado:=True;      except         Ejecutado:=False;         end;//de try except      Result:=Ejecutado;      end; //de EjecutaSQL ------------------------- Then, when I try a SQL.ExecSQL sentence like: BD.EjecutaSQL('INSERT INTO '+Empresa+'_Usuarios '+                          '(Codigo,Descripcion,Clave,Permisos,Empresas) Values ('''                        +eCodigo.Text+''','''                        +eDescripcion.Text+''','''                        +eClave.Text+''','''                        +ePermisos.Text+''','''                        +eEmpresas.Text+''')') It appear to work fine but It doesn't do anything, and, when I try an SQL.Open sentence like: Result:=BD.EjecutaSQL('select * from '+Empresa+'_Usuarios'); I got an SivSeg error and the application crash. It worked fine in windows so I think there is some problem with mdbodbc. What do you think? ---------------------------------------------------------------------- RudieD · 2007-03-13 16:25 After data changes you must Commit the transaction. ---------------------------------------------------------------------- Marc · 2007-03-15 13:28 Quote from: "jluix"Well... Second: At last, I could to link mdb ODBC with unixODBC renaming (create a ln) libodbc.so.0 to libodbc.so This is usually one of the things a -devel package does