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

I am new to database connectivity. I am looking for to connect Microsoft access database connectivity sample code and to update the records from perl. Can someone help me on this?
  • Comment on Microsoft Access database control and UPDATE the records

Replies are listed 'Best First'.
Re: Microsoft Access database control and UPDATE the records
by Sinistral (Monsignor) on May 05, 2009 at 12:54 UTC
Re: Microsoft Access database control and UPDATE the records
by Anonymous Monk on May 05, 2009 at 06:45 UTC
Re: Microsoft Access database control and UPDATE the records
by kennethk (Abbot) on May 05, 2009 at 14:52 UTC
Re: Microsoft Access database control and UPDATE the records
by nikosv (Deacon) on May 06, 2009 at 18:46 UTC
    An example :
    use Win32::OLE::Const 'Microsoft Access'; use Win32; my $access = Win32::OLE->new('Access.Application') or die "Error: Unsuccessful in connecting with Access database.\n"; $access->OpenCurrentDatabase('C:\apasxolhsh\nikos1.mdb'); $access->{Visible}=1; $access->Docmd->OpenForm('er0050-MYFORM'); $access->Forms('er0050-MYFORM')->Controls("code-ypallhloy")->{Value}=1 +400; $access->Forms('er0050-MYFORM')->Controls("date-kinhshs")->{Value}="18 +/08/2008"; $access->Docmd->Quit(acSave);
      Thanks for the reply. use Win32::ODBC; use DirHandle (); use File::Spec (); use HTTP::Date; $DriverType = "Microsoft Access Driver (*.mdb)"; $DSN = "Win32 ODBC --MAOmaoMAOmaoMAO--"; $Dir = "."; $DBase = "Pitstop_files.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"; !$db->Sql($query) or die "couldn't do $query because ", $db->Error(), "\n"; @directory=""; my %WriteFile; my %WriteTime; while($db->FetchRow()) { #print " YES \n"; my %Data = $db->DataHash(); foreach $key (keys(%Data)) { $query = "UPDATE Table1 SET OldFileName='$WriteFile{$key}', OldFileTime='$WriteTime($key)' WHERE Path='$key'"; $db->Sql($query) or die "couldn't do $query because ", $db->Error(), "\n"; } } I am using this code to update my records but it's not working or it will work for first record. Can anybody send me the code to get the datas and update/change the data in mdb file?

        Do format your posts! The Preview is not there just so that you'd have to click twice!

        And use DBI and DBD::ODBC. Win32::ODBC is fairly old and not really supported and definitely not recommended anymore. Once it was the only way, but that's more than ten years ago!

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

Re: Microsoft Access database control and UPDATE the records
by nikosv (Deacon) on May 05, 2009 at 20:18 UTC
    You could use Win32::OLE (and DCOM if the database is remote) and access the Access object model(use methods such as OpenCurrentDatabase etc).I would suggest looking into the Docmd object which is very usefull