Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

How to connect MS Access Database?

by pysome (Scribe)
on Mar 28, 2008 at 03:28 UTC ( #676895=perlquestion: print w/replies, xml ) Need Help??

pysome has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,
I get a MS ACCESS database file (a.mdb) .
Then i upload it to my linux host :/home/test/a.mdb .I wanna to connect this db file by perl script.
BTW,i have installed these module: unixODBC-2.2.12,mdbtools-0.6pre1, and DBD-ODBC-1.15. my script:
use strict; use DBI; my $dbh = DBI->connect("dbi:ODBC:driver=Microsoft Access Driver (*.mdb +, *.accdb);dbq=a.mdb") or die "Can't connect to Database: $DBI::errstr";
But it report a error msg:
DBI connect('driver=Microsoft Access Driver (*.mdb, *.accdb);dbq=a.mdb +','',...) failed: [unixODBC][Driver Manager]Data source name not foun +d, and no default driver specified (SQL-IM002) at ./ line 4 Can't connect to Database: [unixODBC][Driver Manager]Data source name +not found, and no default driver specified (SQL-IM002) at ./ l +ine 4.
How fix this issues? Or any suggestion will be appreciated.

Replies are listed 'Best First'.
Re: How to connect MS Access Database?
by tachyon-II (Chaplain) on Mar 28, 2008 at 04:06 UTC

    Try this:

    my $db = "/home/test/a.mdb"; my $DSN = "driver=Microsoft Access Driver (*.mdb);dbq=$db"; my $dbh = DBI->connect("dbi:ODBC:$DSN",'','') or die "Can't connect to $DSN $DBI::errstr\n";
      Thanks. But the error msg is same as before.:-(

        Get a shell and report back what these commands say (dont type the $ ;-)

        $ odbcinst -q -d $ odbcinst -j

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://676895]
Approved by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2023-03-26 21:25 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.