Hi -

I have never heard of the "Sql" method in DBI. Something like this works:

use strict;
use warnings;
use DBI;

 my $dbh = DBI->connect("DBI:ODBC:cpan")
   || die "could not connect to ODBC:MyDatabase:\n$DBI::errstr\n";

 my $stmt = "select * from modules;";

  my $sth = $dbh->prepare($stmt);
 $sth ||
   die "could not prepare ($stmt):\n$DBI::errstr\n";

 my $rv = $sth->execute
   || die "could not execute ($stmt):\n$DBI::errstr\n";

 while (my $row_ref = $sth->fetchrow_arrayref) {
   print "$_\t" for (@ { $row_ref } );
   print "\n";
   }

 $sth->finish;
 $dbh->disconnect
   || die "could not disconnect to ODBC:MyDatabase:\n$DBI::errstr\n";

Check out DBI.html in your /perl_install_dir/html/site/lib (jf you are
using ActivePerl).

Aloha => Beau.

-----Original Message-----
From: Angel Iliev Kafazov [mailto:angel.kafazov@;mail.bg]
Sent: Wednesday, November 13, 2002 1:04 PM
To: '[EMAIL PROTECTED]'
Subject: accessing ACCESS database


Hi,

I am trying to write a script that copies an information from ACCESS but
it gives me the following error:

Can't call method "Sql" on an undefined value at franowner.pl.txt line 4.

Here's the script:


use Win32::ODBC;
$DSN="db1";
$db = new Win32::ODBC("db1");
$db->Sql("SELECT owner_first_name, owner_last_name FROM Owners WHERE
ID=11");
if ($db->Error()) {
print "Error: $db->Error";
}
statement:\n$DBI:errstr\n";
($ownerfname,$ownerlname) = $db->FetchRow();
print "Database results: first name $ownerfname and last name
$ownerlname\n";
$db->finish;
$db->disconnect || die "Cannot disconnect from database";

Please, help me with this problem.
____________________________________________________
Какво е реклама в Интернет? - http://reklama.mail.bg


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to