Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, i read about the previous questions and answers how to connect to a *.mdb file, but still could not manage to do it. So, again, how can i access a MS Access MDB file, what is the DNS needed and can give one a little example with a specific small db file, please.

Replies are listed 'Best First'.
Re: MS Access DB and WIN32::ODBC or ADO
by buzzcutbuddha (Chaplain) on May 22, 2000 at 17:43 UTC
    I don't know much about the ODBC through Win32, but you can use ADO. I'd be more than
    happy to help. Can you let me know what errors you are getting, because it may be a
    small config error that is preventing your code from working. In the meantime, you can
    check out this node for my previous notes on this issue: RE: ODBC question.
Re: MS Access DB and WIN32::ODBC or ADO
by athomason (Curate) on May 22, 2000 at 12:54 UTC
Re: MS Access DB and WIN32::ODBC or ADO
by Eugene (Scribe) on May 23, 2000 at 00:07 UTC
    Here is the code that I use to connect:

    use Win32::ODBC; $DSN = "DRIVER=Microsoft Access Driver (*.mdb);FIL=MSAccess;DriverId=2 +5;DBQ=F:/webroot/Database/db1.mdb"; (this is the + actual location of your .mdb file)
    Then you declare a new connection like
    $db=new Win32::ODBC($DSN); and run a query: $db->Sql("SELECT * FROM Table"); $db->FetchRow(); %hash = $db->DataHash; $db->Close();
      Ok, I don't know if you are going for portability, or if this will
      working off of one database for it's existence. If it is, you can
      set up an ODBC Connection for the database by using the ODBC icon in
      the Control Panel. This will take care of the DSN for you.

      I'll test out your code and see what errors I get back and let you know.
        i get the following error on my win2k system with the latest version of activestate:
        -==============-
        Can't call method "Sql" on an undefined value at cgi-bin lin e 8.
        -==============-
        i have the code written exactly as it is above, only changing the path to the .mdb file.