PDA

View Full Version : Accessing MS Access DB on Perl Win NT Box


JeffJT
08-03-2006, 02:32 PM
I am trying to access an MS Access DB on an Win NT Box with Perl 5. I have declared use DBI: at the top of the script. The name of the database is paadb.mdb. The address on the host is in the home root directory. When I run the script I get no errors, and nothing displays. The script is as follows:

$strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Server.MapPath(\"../paadb.mdb\")";
$query = "SELECT * FROM user";
$dbh = DBI->connect("DBI:ODBC:$strCon", $dbu, $dbp);
$sth = $dbh->prepare($query)
or die "Can't prepare $query: $dbh->errstr\n";
$rv = $sth->execute
or die "can't execute the query: $sth->errstr";
while (@row= $sth->fetchrow_array()) {
$id = $row[0];
$name = $row[1];
$client = $row[2];
if ($name eq $feed){&checkClient;}
}



Any help would be appreciated. Thanks in advance.
Jeff

tantric
08-08-2006, 09:36 PM
this works for MySQL, perhaps all:

%dBattr = (
PrintError => 0,
RaiseError => 0
);

$dbh = DBI->connect($dB, $user, $pword, \%dBattr) or die("didn't connect", $DBI::errstr);