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_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 
 
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_PASSWD;
$dbh = DBI -> connect("dbi:ODBC:$dsn") || die $DBI::errstr;
$sth = $dbh -> prepare("SELECT * FROM AAA");
$sth -> execute; 
while (@dataref = $ sth -> fetchrow_array) { 
...
}
 
Guillaume 
 
 

Reply via email to