in reply to Trouble with accessing MS Access database via Perl on web host........

I had a look at the docs for DBD::ODBC and found out that you can use database files just like you are doing (but in perl :). DBD::ODBC is a driver for DBI which is usually the recommended system for dealing with databases because it has supports for anything from flatfile databases (DBD::CSV) to getting data from oracle (DBD::Oracle), and all with the same syntax (allowing you to change between them at will).
Here's the code that worked for me to connect to a access database file: my $dbh=DBI->connect("dbi:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=$filename",'','',{RaiseError => 1}); From there everything else is standard DBI syntax which is easy to find examples of.
  • Comment on Re: Trouble with accessing MS Access database via Perl on web host........
  • Download Code

Replies are listed 'Best First'.
Re: Re: Trouble with accessing MS Access database via Perl on web host........
by repson (Chaplain) on Dec 13, 2000 at 14:25 UTC
    Reply to myself :)
    Might as well add this, what to do after you connect...
    my $sth = $dbh->prepare("SELECT email, password FROM surya"); $sth->execute; my $aref = $sth->fetchall_arrayref; $sth->finish; print "Email\tPassword\n"; for my $row (@$aref) { print join("\t",@$row) . "\n"; }
    That would seem to emulate the rest of the functionality of your code except it doesn't output in HTML, have a look at something like HTML::Template for that.
      To Whom It May Concern. I have tried to use Perl DBI and MS Access together for 2 weeks. But even though I programmed the same code as the code is shown above, it keep telling error message: CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: DBI->connect(driver={Microsoft Access Driver (*.mdb)};DBQ=2000ticket) failed: MicrosoftODBC Driver Manager Invalid string or buffer length (SQL-S1090)(DBD: db_login/SQLConnect err=-1) at d:\inetpub\scripts\find_ticket_test.pl line 19 I really do not know what to do. Please answer my question. thank you