Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Accessing Access in Perl

by rpike (Scribe)
on Sep 23, 2010 at 13:59 UTC ( [id://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 testScript.pl line 7 Cannot open the file at testScript.pl line 7.

Replies are listed 'Best First'.
Re^3: Accessing Access in Perl
by Corion (Patriarch) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found