【问题标题】:How do I use SQL to "Show tables" in a MS Access database?如何使用 SQL 在 MS Access 数据库中“显示表”?
【发布时间】:2010-02-11 13:36:38
【问题描述】:

我的代码基于问题Access get all tables 的答案,但出现以下错误:

DBD::ODBC::st 执行失败: [微软][ODBC微软访问 Driver] 无法读取记录;不 'MSysObjects' 的读取权限。 (SQL-42000) 在 direct.pl 第 22 行。

[Microsoft][ODBC Microsoft Access Driver] 无法读取记录;不 'MSysObjects' 的读取权限。 (SQL-42000) 在 direct.pl 第 22 行。

这是我到目前为止所尝试的。我注释掉了我的第一次尝试。当前的尝试是基于SELECT "Table" AS [Table],而旁观者在他对question的回答中提到了这一点。无论哪种方式,我都会遇到相同的错误。这是我的完整代码:

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";
}

【问题讨论】:

标签: sql perl ms-access ms-access-2007 dbi


【解决方案1】:

【讨论】:

猜你喜欢
  • 2019-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多