#!C:/Perl/bin/perl -w
use DBI;
my $DIR_PATH = 'C:/Perl/';
my $DBASE_NM = 'AccessDB.accdb';
my $TABLE_NM = "EMPLOYEE";
my $dsn = 'dbi:ODBC:driver=Microsoft Access Driver (*.mdb, *.accdb);dbq=' . $DIR_PATH . $DBASE_NM;
my $dbh = DBI->connect($dsn,undef,undef) || die "Can't reach database: $DBI::errstr";
my $sql = "SELECT * FROM $TABLE_NM";
# my $sql = "SELECT * FROM $TABLE_NM WHERE ACTIVE_IND='N'";
$sth = $dbh->prepare($sql);
$sth->execute || die "Could not execute SQL statement: DBI::errstr";
while (@row=$sth->fetchrow_array())
{
print "@row\n";
}
$sth->finish;
$dbh->disconnect;
*Note : This script can be used to execute simple database queries without any database installed on local machine.
use DBI;
my $DIR_PATH = 'C:/Perl/';
my $DBASE_NM = 'AccessDB.accdb';
my $TABLE_NM = "EMPLOYEE";
my $dsn = 'dbi:ODBC:driver=Microsoft Access Driver (*.mdb, *.accdb);dbq=' . $DIR_PATH . $DBASE_NM;
my $dbh = DBI->connect($dsn,undef,undef) || die "Can't reach database: $DBI::errstr";
my $sql = "SELECT * FROM $TABLE_NM";
# my $sql = "SELECT * FROM $TABLE_NM WHERE ACTIVE_IND='N'";
$sth = $dbh->prepare($sql);
$sth->execute || die "Could not execute SQL statement: DBI::errstr";
while (@row=$sth->fetchrow_array())
{
print "@row\n";
}
$sth->finish;
$dbh->disconnect;
*Note : This script can be used to execute simple database queries without any database installed on local machine.
No comments :
Post a Comment