You should check the return status of calls like connect(), prepare() and execute(). That error message will result if the call to execute() fails. It means that $rs is 'undef'.
 
Checking the man page 'perldiag' and searching for 'without a package or object' turns up:
 
     Can't call method "%s" without a package or object reference
         (F) You used the syntax of a method call, but the slot
         filled by the object reference or package name contains
         an expression that returns a defined value which is
         neither an object reference nor a package name.
         Something like this will reproduce the error:
 
             $BADREF = 42;
             process $BADREF 1,2,3;
             $BADREF->process(1,2,3);
 
 
(I'm not sure that this description helps much ;)

--
Hank Barta
At The Hull Group, Chicago
(312) 655-4636

-----Original Message-----
From: bage [mailto:[EMAIL PROTECTED]]
Sent: Sunday, September 16, 2001 5:05 AM
To: [EMAIL PROTECTED]
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_PASSWD;
$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

Reply via email to