Re: How to access MS Access from Perl?

From: luican (luican_at_yaNooSpammhoo.com)
Date: 06/03/04

  • Next message: Manasa: "Perl equivalent of mysql "like""
    Date: Thu, 03 Jun 2004 17:47:48 GMT
    
    

    Thanks Aaron. Here's an example I modified using Win32::ODBC and an ODBC
    data source to the Northwind database.
    What benefits will DBI provide?

    lc

    use Win32::ODBC;
        $db = new Win32::ODBC( "northwind" ) || die "Error connecting: " .
    Win32::ODBC::Error();

        if( ! $db->Sql( "SELECT CustomerID FROM customers" ) ) {
            while( $db->FetchRow() ) {
                %Data = $db->DataHash();
                @key_entries = keys(%Data);
                $Row++;
                print "$Row)";
                foreach $key ( keys( %Data ) )
                {
                    print "\t'$key' = '$Data{$key}'\n";
                }
            }
        }
        else
        {
            print "Unable to execute query: " . $db->Error() . "\n";
        }
            $db->Close();

    "Aaron W. West" <tallpeak@hotmail.NO.SPAM> wrote in message
    news:rr2dnWe6vr0NBiDd38DK-w@speakeasy.net...
    > Email to luican@yahoo.com bounces.
    >
    > Anyway, try DBI and DBD::ODBC. Or maybe DBD::ADO, but I've never tried it.
    >
    > ----------------------------------------
    >
    > http://cpan.org
    >
    > http://search.cpan.org/~jurl/DBD-ODBC-1.09/ODBC.pm
    >
    > ..
    > Connect without DSN The ability to connect without a full DSN is
    introduced
    > in version 0.21.
    >
    > Example (using MS Access): my $DSN = 'driver=Microsoft Access Driver
    > (*.mdb);dbq=\\\\cheese\\g$\\perltest.mdb'; my $dbh =
    > DBI->connect("dbi:ODBC:$DSN", '','') or die "$DBI::errstr\n";
    >
    > The above sample uses Microsoft's UNC naming convention to point to the
    > MSAccess file (\\\\cheese\\g$\\perltest.mdb). The dbq parameter tells the
    > access driver which file to use for the database.
    >
    > ..
    > ----------------------------------------
    > One thing you might try is setting the default bind type to varchar as I
    did
    > for MS SQL Server, if you have date conversion errors. But it may not be
    > relevant to MS Access:
    >
    > # This is needed to avoid needless sql_describe_params,
    > # and errors inserting datetime values
    > # It emulates old DBI 0.28 behavior:
    > $dbh->{odbc_default_bind_type} = 12; # SQL_VARCHAR; #12
    >
    > ----------------------------------------
    >
    > http://search.cpan.org/~sgoeldner/DBD-ADO-2.91/lib/DBD/ADO.pm
    >
    > ..
    > The DBD::ADO module supports ADO access on a Win32 machine.
    > ..
    >
    >
    > ----- Original Message -----
    > From: "luican" <luican@yaNooSpammhoo.com>
    > Newsgroups: comp.lang.perl
    > Sent: Tuesday, June 01, 2004 12:07 PM
    > Subject: How to access MS Access from Perl?
    >
    >
    > Hi,
    >
    > Good day! I am writing some Perl script on the server side for HTML
    forms
    > that can create/update an MS Access database. Does anyone know of examples
    > how this can be done?
    >
    > Your help is greatly appreciated.
    >
    > -lc
    >
    >
    >
    >


  • Next message: Manasa: "Perl equivalent of mysql "like""

    Relevant Pages

    • Re: Mail-merging with Word, MySQL... and Perl?
      ... Alt+F9 to toggle off their display. ... connection to my MySQL database on my Linux box. ... Or if a couple has its anniversary listed, I'll want to format ... the Perl script directly (which would be written to generate that data in ...
      (microsoft.public.word.mailmerge.fields)
    • Re: DBI with ORACLE encryption
      ... perl script to pull data out of the interface and dump the same to the ... All we do with oracle is to take an database connection ... other ways of connecting to database using dbi. ...
      (perl.dbi.users)
    • Memory fault(coredump) with two DBD type connections
      ... successfully connect to Oracle databases via a Perl script. ... can successfully connect to DB2 databases via a Perl script. ... when I try to connect to the same Oracle database AND same DB2 database ... 27203 Allow compiling swigged C++ code ...
      (perl.dbi.users)
    • perl with mysql which takes a file as a input that contains t he info to create the tables
      ... inserting values into the database. ... only procedure for taking input from a file (using perl script) into ... MySQL database is through place holders. ... Where the passlist.txt hav the data in the format ...
      (perl.beginners)
    • Re: connect to a remote Postgresql server using DBI
      ... else) to execute queries on the remote database. ... perl script to execute queries on the remote server? ... > See the bottom of this page for client installation ...
      (perl.dbi.users)

    Loading