Guillaume Bedard ([EMAIL PROTECTED]):
> bage wrote :
> > Sent: 16 septembre, 2001 06:05
> > Subject: DBI problem
> > Hi, all
> > I have a problem when using Perl DBI module, below is my code:
> > - code -
> > use DBI;
> > $dsn = "driver={SQL
> Server};Server=$DB_SERVER;database=$USED_DB;uid=".$DB_USER.";pwd=".$DB_PASSW
> D;
> > $dbh = DBI -> connect("dbi:ODBC:$dsn") || die $DBI::errstr;
> > $sth = $dbh -> prepare("SELECT * FROM AAA");
> > $rs = $sth -> execute;
> > while (@dataref = $rs -> fetchrow_array) {
> > ...
> > }
> > - code end -
> > The error message is: Can't call method "fetchrow_array" without a
> package or object reference at line ..
> > Why I can't call fetchrow_array method?
> > Anyone can help me? I very appreciated your help! :)
> > bage
> The error message means you can not call the method "fetchrow_array" on the
> package $rs. You should call the method on the statement handle : $sth.
> $dsn = "driver={SQL
> Server};Server=$DB_SERVER;database=$USED_DB;uid=".$DB_USER.";pwd=".$DB_PASSW
> D;
$dbh = DBI ->> connect("dbi:ODBC:$dsn") || die $DBI::errstr;
$sth = $dbh ->> prepare("SELECT * FROM AAA");
$sth ->> execute;
> while (@dataref = $ sth -> fetchrow_array) {
> ...
> }
This is exactly the same thing except you re-used the $sth variable
for the returned record set.
The problem is likely that $sth->execute returned 'undef' because of
an error condition. As Hank suggested, you should look at the return
codes and $dbi->errstr messages to determine what the problem was and
codes and handle errors completely.
--
Jeremy Wadsack
Wadsack-Allen Digital Group
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl