Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Santa Monica, CA

    Unhappy Unanswered: How can access a Microsoft Acces database from Perl


    I am actually learning Perl and would like to connect my Access database in my Window XP. I made some search and I already found that I have the DBI module installed in my PC.
    My problem is how can I installed the DBD module. I don't know which DBD module I need (I looked in the but couldn't find any information for Microsoft Access).


    1) It seams that I need the DBD:ODBC module, can you confirm this information? And where can I download it? I don't have the command PPM available.....

    2) I actually don't have ODBC in my computer. Where can I find one for Windows XP?

    3) Do you know a web page where I could find all this information?

    Thank you so much for your help.

    Student lost.....

  2. #2
    Join Date
    Jun 2004
    Nowhere Near You
    For OCBC: Try


    For PPM: Since you're running Windows you might as well use ActivePerl from Installing ActivePerl will "give" you PPM.

  3. #3
    Join Date
    Jan 2004
    Two samples of code how to connect an Access DB:
    #! c:\perl\bin\perl
    use Win32::ODBC;
    $DriverType = "Microsoft Access Driver (*.mdb)";
    $DSN = "Win32 ODBC --MAOmaoMAOmaoMAO--";
    $Dir = "c:\\meinOrdner";
    $DBase = "meineDB.mdb";
    Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType,("DSN=$DSN", "Description=MAO Win32 ODBC Test DSN for Perl", "DBQ=$Dir\\$DBase", "DEFAULTDIR=$Dir", "UID=", "PWD=")) or die "ConfigDSN(): Could not add temporary DSN" . Win32::ODBC::Error();
    $db=new Win32::ODBC($DSN) or die "couldn't ODBC $DSN because ", Win32::ODBC::Error(), "\n";
    $query = "select * from table1, table2 where table1.spalte = table2.spalte";
    !$db->Sql($query) or die "couldn't do $query because ", $db->Error(), "\n";
     my %Data = $db->DataHash();
     foreach my $key(keys(%Data)){
       print $key," -> ",$Data{$key};
    Win32::ODBC::ConfigDSN(ODBC_REMOVE_DSN, $DriverType, "DSN=$DSN") or die "ConfigDSN(): Could not remove temporary DSN because ", Win32::ODBC::Error();
    use DBI;
    #open connection to Access database
    $dbh = DBI->connect('dbi:ODBC:driver=microsoft access driver (*.mdb);dbq=C:\Windows\Desktop\meineDB.mdb');
    #prepare and execute SQL statement
    $sqlstatement="SELECT * FROM table1, table2 WHERE table1.spalte = table2.spalte";
    $sth = $dbh->prepare($sqlstatement);
    $sth->execute || 
          die "Could not execute SQL statement ... maybe invalid?";
    #output database results
    while (@row=$sth->fetchrow_array()){ 
       print "@row\n";
    Here you can find Win32::ODBC and DBD::ODBC : - The German Perl-Community

  4. #4
    Join Date
    Jan 2004
    Santa Monica, CA

    Thumbs down Need more help....

    In first thank you for your help....

    I found my ODBC without problem.... (Senza Nome reply)

    I load ActivePerl (I removed indogoperl before) but I didn't be able to work with it (I couldn't find my cgi-bin directory, no Apache server, I think that I need to be more proficient with Perl to use this version) (Senza Nome reply).

    So I load again my indigoperl version and everything work well.

    I tried to load the DBD:ODBC module but I had so many problem that I decided to work with WIN32::ODBC. But I still can't do anything....

    These is the steps that I did:

    1) Download of the
    2) Uncompress the zip and move the directory to C:/Perl/perl/lib/.
    Now the module' files are on: C:/Perl/perl/lib/libwin32-0.191/
    3) I read the README.txt and type the following command without success:

    cd c:\Perl\perl\lib\libwin32-0.191

    perl Makefile.PL

    I received the following message:

    Checking if your kit is complete...
    Looks good

    Error: Unable to locate installed Perl libraries or Perl source code.

    It is recommended that you install perl in a standard location before building extensions. Some precompiled versions of perl do not contain these header files, so you cannot built extensions. In such a case, please build and install you perl from a fresh perl distribution. It usually solves this kind of problem.

    (You get this message, because MakeMaker could not find “W:\dev\indigoperl\indigoperl\perl\lib\CORE\perl.h ”.

    What need I to do? I am lost and frustrated….

    Thank you for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts