469,295 Members | 1,991 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,295 developers. It's quick & easy.

Using a MS Access Database?

Does PERL supports MS Access database?
Aug 9 '07 #1
4 2269
miller
1,089 Expert 1GB
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.

- MODERATOR
Aug 9 '07 #2
numberwhun
3,503 Expert Mod 2GB
Does PERL supports MS Access database?
Why yes, yes it does. In fact, Perl supports many databases, including flatfile type db's.

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,

Jeff
Aug 9 '07 #3
yes it supports... see the following code for reference...

Expand|Select|Wrap|Line Numbers
  1. use DBI;
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. #######################################
  7. # Script Parameters
  8. #######################################
  9.  
  10. my $raj = $ARGV[0];
  11.  
  12. #######################################
  13. # open connection to Access database
  14. #######################################
  15.  
  16. my $dbh = DBI->connect('dbi:ODBC:driver=microsoft access driver (*.mdb); dbq=C:\pp\emp.mdb')
  17.     or die "Cannot connect: $DBI::errstr";
  18.  
  19. #prepare and execute SQL statement
  20.  
  21. my $rsth = $dbh->prepare(qq{SELECT emp.emp_id, emp.name, emp.designation, emp.start_date FROM emp});
  22. $rsth->execute or die $dbh->errstr;
  23.  
  24. my ($emp_id, $name, $designation, $start_date); # Declare columns
  25. $rsth->bind_columns(\$emp_id, \$name, \$designation, \$start_date);
  26.  
Aug 10 '07 #4
miller
1,089 Expert 1GB
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,
- Miller
Aug 11 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

38 posts views Thread by Remco Groot Beumer | last post: by
8 posts views Thread by Carl | last post: by
6 posts views Thread by Serious_Practitioner | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.