Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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 ./test.pl line 4 Can't connect to Database: [unixODBC][Driver Manager]Data source name +not found, and no default driver specified (SQL-IM002) at ./test.pl l +ine 4.
How fix this issues? Or any suggestion will be appreciated.
Thanks

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2023-06-07 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?