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

danger_will_robinson:

Have you installed DBD::ADO? The DBI driver needs an appropriate DBD interface for your database.

Also, if you move your prepare statement before the loop, it may make things go a bit quicker:

open my $FILEHANDLE,$FilePath or die "Failure opening CSV file for rea +ding: " . $!; my $InsertUserQuery = "INSERT INTO Users (Username,FullName,FirstName, +LastName) VALUES (?,?,?,?);"; my $InsertUserResult = $DBHandle->prepare($InsertUserQuery); while (<$FILEHANDLE>) { chomp; next if /Last Name/; my ($LastName,$FirstName,$GUID) = split (/\t/,$_); $LastName =~ s/"//g; $FirstName =~ s/"//g; $GUID =~ s/"//g; my $FullName = $FirstName . " " . $LastName; &Echo("Inserting $FullName"); $InsertUserResult->execute($GUID,$FullName,$FirstName,$LastName); } close $FILEHANDLE;

...roboticus

You bubble-headed booby! --Dr. Smith

(Sorry for the cheap joke.)

  • 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 Anonymous Monk on Jun 02, 2012 at 23:55 UTC
    Yep, I just double checked and CPAN tells me that I have the most up to date version (2.99).

      will_danger:

      Then I'm guessing the "Microsoft.ACE.OLEDB.12.0" bit isn't installed on your machine. I did a quick google for "ado connection string access" and found http://www.connectionstrings.com/access. Perhaps using "Microsoft.Jet.OLEDB.4.0" may work? (I don't use Access, so I'm not familiar with those connection strings.)

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        It was a good guess, but alas, no dice. I tried the Jet connection string, with a few modifications, along with a few others. The errors I then get come from the DBI module itself, telling me that it doesn't know what drivers to use based on the connection string I am passing in. "....because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver' prefix and the DBI_DRIVER env var is not set)...".

        I've tried re-exporting the file as an old style .mdb file and that didn't work either. I am expanding my search a bit because this is definitely not a perl problem, but something weird with my computer or office itself.

        Thanks for hanging out.