Does PERL supports MS Access database?
Using a MS Access Database?
Collapse
X
-
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.
- MODERATOR -
Why yes, yes it does. In fact, Perl supports many databases, including flatfile type db's.Originally posted by ashokbioDoes PERL supports MS Access database?
You will want to have a read of the DBI module description on CPAN. DBI is the module that interfaces with all of the popular databases, simplifying your interaction with the DB you wish to use.
Regards,
JeffComment
-
yes it supports... see the following code for reference...
[CODE=perl]
use DBI;
use strict;
use warnings;
############### ############### #########
# Script Parameters
############### ############### #########
my $raj = $ARGV[0];
############### ############### #########
# open connection to Access database
############### ############### #########
my $dbh = DBI->connect('dbi:O DBC:driver=micr osoft access driver (*.mdb); dbq=C:\pp\emp.m db')
or die "Cannot connect: $DBI::errstr";
#prepare and execute SQL statement
my $rsth = $dbh->prepare(qq{SEL ECT emp.emp_id, emp.name, emp.designation , emp.start_date FROM emp});
$rsth->execute or die $dbh->errstr;
my ($emp_id, $name, $designation, $start_date); # Declare columns
$rsth->bind_columns(\ $emp_id, \$name, \$designation, \$start_date);
[/CODE]Comment
-
Greetings crazy4perl,
Thank you for sharing your code to connect to a MS Access Database.
Please note that I've cleaned up your syntax and formatting some for you. Specifically, take note of the use of $dbh->errstr in the error conditions now. This is typically how one gets detailed information on a DBI error. Also, the line at the beginning should be "use strict;" and not "use STRICT;".
Kudos,
- MillerComment
Comment