#!/usr/bin/perl
use warnings;
use strict;
use DBI;
use DBD::ODBC;
$username = "";
$pwd = "";
my $dbh = DBI->connect("DBI:ODBC:Employee", $username, $pwd) or
die("Couldn't make connection to database:$DBI::errstr");
#注意:这里的Employee是你刚才填数据源时填入的名字
my $sth = $dbh->prepare(q{SELECT * FROM employee}) or
die("Cannot prepare statement:", $dbh->errstr(),"\n");
my $rc = $sth->execute() or
die("Cannot execute statement:", $sth->errstr(), "\n");
my @array;
while (@array = $sth->fetchrow_array()) {
write();
}
warn($DBI::errstr) if $DBI::err;
$dbh->disconnect();
$sth->finish();
format STDOUT =
@<<<<<<@<<<<<<<<<@<<<<<<<<<<@<<<<<@<<<<<<<<<@<<<<<<<<<<<<<<
$array[0],$array[1],$array[2],$array[3],$array[4], $array[5]
.
|