Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: Accessing Access in Perl

by rpike (Scribe)
on Sep 23, 2010 at 13:59 UTC ( #861539=note: print w/replies, xml ) Need Help??

in reply to Re: Accessing Access in Perl
in thread Accessing Access in Perl

Do you have a simple example? I'm trying a few approaches and none seem to work (the directory for the mdb specified below may differ from what I originally posted). For example,
DBI->connect( "dbi:ODBC:driver=Microsoft Access Driver(*.mdb);dbq=C:/D +ownload/tmp/examples.MDB",'','') or die "Cannot open the file";
I get the error : DBI connect('driver=Microsoft Access Driver(*.mdb);dbq=C:/Download/tmp/examples.MDB','',...) failed: MicrosoftODBC Driver Manager Data source name no t found and no default driver specified (SQL-IM002) at line 7 Cannot open the file at line 7.

Replies are listed 'Best First'.
Re^3: Accessing Access in Perl
by Corion (Pope) on Sep 23, 2010 at 14:03 UTC

    I use the following:

    $dsn ||= "dbi:ODBC:driver=Microsoft Access Driver (*.mdb);dbq=$dbfile" +;

    Note that I have different whitespace. I assume that whitespace is significant.

    $dbfile is a filename with backslashes, which should not be significant, but you might want to try both.

      I must have left something out cause although I thought that is what I had in there it didn't work. I copied your post and it appears to work. Do you have a very simple, generic piece a code that selects everything from the database and prints it to the screen? I'm uncertain of the format and what data is in this database so I need to loop through and print some of the content to screen. One great approach would be to see the structure of the database. I haven't worked on Access/SQL in such a long time so I apologize for some of these noob-like questions. Thanks so much for the help.

        Have you tried opening the file in Access? I find Access a much more convenient application. Alternatively see Querylet.

        Maybe you are looking for a generic SQL statement to list things?

        select * from $tablename

        will give you the contents of a table.

Re^3: Accessing Access in Perl
by mje (Curate) on Sep 23, 2010 at 14:12 UTC

    I think you need to put {} around some key values in your connection string - they quote the value. Also you slashes are the wrong way around in the filespec.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://861539]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-11-21 22:14 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (312 votes). Check out past polls.