
yim11
Novice
Jan 11, 2001, 2:45 PM
Post #1 of 1
(207 views)
|
|
Help needed w/a Script to query Access DB
|
Can't Post
|
|
Hello! 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! -Jim 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, $query->start_html(-title=>'RSPR'), 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 $sel->finish; $dbh->disconnect; exit; ---End Script---
|