jeff867 has asked for the wisdom of the Perl Monks concerning the following question:
I am using DBI for the first time and am able to use fetchrow_array without any problems. It returns data as I would expect.
My problem arises when I attempt to use fetchrow_hashref. This does not appear to work correctly. I am using Win2K with an Access db.
I have gone through piles of other examples on this site and others, but still no luck - is it my code? am I blind and missing something??use DBI; use DBD::ODBC; my $DSN = 'perltest'; my $dbh = DBI->connect("dbi:ODBC:$DSN", '','') || die "$DBI::errstr\n" +; my $sql; # there are three rows that match this select statement $sql = "SELECT * FROM contacts WHERE phone = '8675309'"; $sth = $dbh->prepare($sql); $sth->execute; # this works fine as it displays the first row of data @row = $sth->fetchrow_array; print "@row<br>\n"; # this does not work - displays a blank line $hashrow = $sth->fetchrow_hashref; print "$hashrow{phone} <br>\n"; $sth->finish(); $dbh->disconnect();
Any help you could offer would be appreciated
-Jeff
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: DBI and fetchrow_hashref
by jeffa (Bishop) on May 08, 2002 at 00:18 UTC | |
|
Re: DBI and fetchrow_hashref
by usrbinperl (Initiate) on May 08, 2002 at 00:27 UTC | |
by jeff867 (Initiate) on May 08, 2002 at 00:33 UTC | |
|
Re: DBI and fetchrow_hashref
by jsprat (Curate) on May 08, 2002 at 00:30 UTC | |
|
Re: DBI and fetchrow_hashref
by mephit (Scribe) on May 08, 2002 at 05:22 UTC |