Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: How to link Ms-access data's in perl

by monkfan (Curate)
on Apr 05, 2005 at 05:35 UTC ( #444865=note: print w/replies, xml ) Need Help??

in reply to How to link Ms-access data's in perl

Try this.
#Windows-based Perl/DBI/MS Access example use DBI; #open connection to Access database $dbh = DBI->connect('dbi:ODBC:Clients'); #prepare and execute SQL statement #note that the query ClientName etc below is just the example # suit it with your own requirement $sqlstatement="SELECT ClientName,ClientEmail FROM billing"; $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" }
If Microsoft Access is open and running while you try to execute these Perl scripts you may run into resource conflicts. If so, simply shutdown Microsoft Access before using Perl.

For further info read DBI module, besides searching the wealth of Perlmonks is always useful.


Replies are listed 'Best First'.
Re^2: How to link Ms-access data's in perl
by ikegami (Pope) on Apr 05, 2005 at 05:41 UTC

    ADO supposedly works great:

    my $db_file = 'd:\path\to\database.mdb'; my $db_user = 'username'; my $db_passwd = 'pasword'; my $dbh = DBI->connect( 'dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0;Data Source='.$db_file, $db_user, $db_passwd ) or die $DBI::errstr; ...

    It bypasses ODBC which ends up connecting to the Jet Engine anyway. It also saves you from creating ODBC DSNs in the Control Panel. (yeah, I suppose you could use DSN-less ODBC connection, but people don't seem to do that for some reason.)

    Update: oops, this was supposed to be a reply to the OP.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://444865]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2018-01-16 16:22 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (182 votes). Check out past polls.