Recent

Author Topic: Connecting mdb Database via ODBC in linux  (Read 16943 times)

jluix

  • New Member
  • *
  • Posts: 19
Connecting mdb Database via ODBC in linux
« on: March 10, 2007, 06:29:30 pm »
Hi!

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.

bram

  • Newbie
  • Posts: 5
RE: Connecting mdb Database via ODBC in linux
« Reply #1 on: May 02, 2007, 12:17:35 am »
Try to install the unixodbc-dev package as well:
Code: [Select]
aptitude install unixodbc-dev

This adds the correct symlink libodbc.so in /usr/lib.

I do not know the exact cause, but it might have to do with giving you the option to choose between iodbc and unixodbc (iodbc is an alternative ODBC driver manager). Note: I only tested odbcconn with unixodbc.

bram

  • Newbie
  • Posts: 5
RE: Connecting mdb Database via ODBC in linux
« Reply #2 on: May 02, 2007, 12:24:35 am »
And if you don't want to pull in the unixodbc-dev dependencies (e.g. on a debian server), you can add the link yourself:
Code: [Select]
ln -s libodbc.so.1.0.0 /usr/lib/libodbc.so

 

TinyPortal © 2005-2018