Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

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


Comment on Re: How to link Ms-access data's in perl
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2014-11-24 18:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (144 votes), past polls