CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Help needed w/a Script to query Access DB



Jan 11, 2001, 2:45 PM

Post #1 of 1 (652 views)
Help needed w/a Script to query Access DB Can't Post

I have Perl script that talks with the Northwinds example database in MS Access using an ODBC DSN of Northwind.

My problem is that the script only returns the first 4 values from the database table when run.
My question is how can I fix the script to display all the results?
Many Thanks in advance!

The script follows:
---Begin script---

use CGI;
use DBI;
use Data::Dumper;
my $query = new CGI;
my $dbh = DBI->connect( "dbi:ODBC:northwind", "", "", {RaiseError => 1, PrintError => 1, AutoCommit => 1} ) or
die "Unable to connect: " . $DBI::errstr . "\n";

# OK, connected, now select from Customers table.

my $sel = $dbh->prepare( "select * from Customers where CustomerID like ?" );

$sel->execute( qq{A%} );
print $query->header,

print "Driver : " . $dbh->{Driver}->{Name} . "\n";
print "\n";
print "<P>";
print "SQL Statement: " . $sel->{Statement} . "\n";
print "<P>";
print "Table contains: " . $sel->{NUM_OF_FIELDS} . " columns.\n";
print "<P>";
print "Column names are: " . join( "\n\t", @{$sel->{NAME}}, "" );
print "<P>";
print "Number of Params: " . $sel->{NUM_OF_PARAMS} . "\n";
print "<P>";

{ my @row;
while (@row = $sel->fetchrow_array) {
print join( "\t",@row, "\n");}

print "\n";
# Finished

---End Script---


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives