in reply to How can I connect my perl script to an Access 2010 (.accdb) file?

I found this connection string in some old code I wrote - it worked at that time (circa 2005) ....
use DBI; use DBD::ODBC; my $DBFile= q(TestLog.mdb); if (-e $DBFile){ print "Using existing database:$DBFile\n"; } my $DSN = "driver=Microsoft Access Driver (*.mdb);dbq=$DBFile"; my $dbh = DBI->connect("dbi:ODBC:$DSN", undef,undef) or die "$DBI::err +str\n";

             I hope life isn't a big joke, because I don't get it.
                   -SNL

  • Comment on Re: How can I connect my perl script to an Access 2010 (.accdb) file?
  • Download Code

Replies are listed 'Best First'.
Re^2: How can I connect my perl script to an Access 2010 (.accdb) file?
by will_danger (Initiate) on Jun 03, 2012 at 02:06 UTC

    I gave it a shot, no luck unfortunately. I've now re-installed Strawberry a few times (trying different perl versions, while fetching fresh modules each time) and installed IIS (because I figured that maybe there were components there I might have needed), aside from trying out your snippet (and installing the necessary module). The error I got was:

    "DBI connect('driver=Microsoft Access Driver (*.mdb);dbq=KosJourney.mdb',',...) failed: MicrosoftODBC Driver Manager Data source name not found and no default driver specified (SQL-IM002) at PopulateUsersFromResultCSV.pl line 23"

      I've got it!

      The problem was architecture. Even though my OS is 64 bit, my Office install (which is what I guess determines the architecture of the data access components), is 32 bit. There seemed to have been a communication issue where DBI interacted with the native data access stuff through Microsoft. I uninstalled Strawberry Perl 64 bit, deleted the CPAN modules (since it leaves it there after uninstall), and re-installed SP 32-bit. Then re-downloaded and re-compiled the CPAN modules and...there it is!

      All of my queries are running happily now. Thanks to those who chimed in. On to the next crisis.

        For the archive: There are two distinct ODBC data source managers on Windows 64 bit editions, the obvious one works for 64 bit, the "hidden" one works for 32 bit. This is documented in DBD::ODBC::FAQ.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)