[Gambas-user] accessing mdb files

Willy Raets willy at ...2734...
Mon Aug 26 22:34:47 CEST 2013


On Mon, 2013-08-26 at 21:23 +0200, Fernando Martins wrote:
> On 08/26/2013 07:39 PM, Randall Morgan wrote:
> > Linux does not have direct support for mdb as far as I am aware.
> >
> >
> There is mdbtools, which includes a primitive odbc driver, that I was 
> trying to use.
> 
> http://mdbtools.sourceforge.net/
> 
> Regards,
> Fernando

I made a small example project that makes a connection to a .mdb

This is how it is possible (I only tested the connection, not reading in
tables or changing any records):

1. Install Mdbtools -> this will install all needed libraries
2. Locate libmdbodbc.so.1 (or libmdbodbc.so.0) -> you need the full path
to it for next step
3. Edit odbc.ini with elevated user rights (located in /Etc)

My odbc.ini for this example looks like this

[DataEnquete]
Description = MS Access ODBC 
Driver = /usr/lib/i386-linux-gnu/odbc/libmdbodbc.so.1
Database = /home/willy/Databases/DataEnquete-Transport.mdb

IN LINE with Driver =
Replace with full path to your libodbcmdb.so.1 (or libodbcmdb.so.0)
IN LINE with Database
Replace with full path to the .mdb you want to open

Use [DataEnquete] without [ and ] (so DataEnquete) for .Host in your
ODBC connection code
OR replace DataEnquete with MyName in .Host and [DataEnquete] with
[MyName] in odbc.ini

Code for connecting looks like this:

Private myMdbConnect As New Connection

Private Sub Connect()

   With myMdbConnect
      .Type = "odbc"
      .Host = "DataEnquete"
      .Login = "Admin"     ' <- It's necesary for mdb
      .Name = ""           ' <- In odbc always keep blank
   End With
   myMdbConnect.Open  

End

Attached a Source Archive.
To make it work first do the steps mentioned above and adapt all to your
code to the content of your odbc.ini.



> 
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and 
> AppDynamics. Performance Central is your source for news, insights, 
> analysis and resources for efficient Application Performance Management. 
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org



-------------- next part --------------
A non-text attachment was scrubbed...
Name: ConnectToMdb-0.0.1.tar.gz
Type: application/x-compressed-tar
Size: 5824 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130826/0acee8e0/attachment.bin>


More information about the User mailing list