我正在尝试从Access表中检索数据。 代码如下:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $DBFile = qw(C:test\INSTRUCTIONS.mdb );
my $dbh = DBI->connect("dbi:ODBC:driver=microsoft access driver (*.mdb);dbq=$DBFile",'','') or die("cannot connect to DB");
my $SQLquery = "select * FROM IndemDate";
$dbh->Execute($SQLquery);
我收到的错误信息如下:
DBI connect('driver=microsoft access driver (*.mdb);dbq=C:test\INSTRUCTIONS.mdb','',...) failed: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002) at C:/Test/connectaccess.pl line 9.
cannot connect to DB at C:/Test/connectaccess.pl line 9.
请问有人能帮我纠正错误吗?是否有我遗漏需要安装的驱动程序?
my $DBFile = 'C:/test/INSTRUCTIONS.mdb'; die "文件路径有问题" if not -e $DBFile;
来检查是否存在问题。也许在传递该参数时有问题...您可以使用这些行来检查是否像我所写的那样。 - Filippo Lauriaq()
替换qw()
,我仍然会收到相同的错误。 - Programmer