I based my code on the answer to the question Access get all tables, but am getting the following error:
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'MSysObjects'. (SQL-42000) at direct.pl line 22.
[Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'MSysObjects'. (SQL-42000) at direct.pl line 22.
Here is what I have tried so far. I commented out my first attempt. The current attempt is based on SELECT "Table" AS [Table] which astander mentioned in his answer to said question. I get the same error either way. Here is my code, in its entirety:
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect('DBI:ODBC:MutantDB','','')
or die 'could not connect to database' . DBI::errstr;
my $sth = $dbh->prepare('SELECT "Table" AS [Table],
MSysObjects.Name,
MSysObjects.Type
FROM MSysObjects
WHERE MSysObjects.Type =1
Or MSysObjects.Type=6
ORDER BY MSysObjects.Name;')
or die 'could not prepare statement' . $dbh->errstr();
# my $sth = $dbh->prepare('SELECT MSysObjects.*, MSysObjects.Type
# FROM MSysObjects
# WHERE (((MSysObjects.Type)=1)) OR (((MSysObjects.Type)=6));'
# ) or die 'could not prepare statment' . $dbh->errstr();
$sth->execute() or die $sth->errstr();
while( my ($name, $type) = $sth->fetchrow()){
print "name: $name \t type: $type \n";
}