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

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

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


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

Hi,
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.

Regards,
Edward

Replies are listed 'Best First'.
Re^2: How to link Ms-access data's in perl
by ikegami (Patriarch) 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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://444865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-16 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found