将Perl连接到MS Access [英] Connect perl to ms access

查看:71
本文介绍了将Perl连接到MS Access的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图从Access中的表中检索数据.代码是

I am tring to retrive data from a table in access. The code is

#!/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.

有人可以帮助我纠正我的错误吗?有没有我想安装的驱动程序.

can someone help me rectify my error. Is there any driver I've missed to install.

推荐答案

如问题注释所示,Perl脚本最初是作为64位进程运行的.因此,较旧的Microsoft"Jet" ODBC驱动程序

As indicated in the comments to the question, the Perl script was originally running as a 64-bit process. Therefore the older Microsoft "Jet" ODBC driver

Microsoft Access Driver (*.mdb)

不可用.只有32位进程可以使用较旧的Jet驱动程序.如果必须将您的Perl脚本作为64位进程运行,则必须从此处,然后使用驱动程序名称

was not available. Only 32-bit processes can use the older Jet driver. If you must run your Perl script as a 64-bit process then you will have to download and install the 64-bit version of the newer Microsoft Access Database Engine (a.k.a. "ACE") from here and then use the driver name

Microsoft Access Driver (*.mdb, *.accdb)

或者,您可以将Perl脚本作为32位进程运行,并使用较旧的Jet驱动程序.

Or, you could run your Perl script as a 32-bit process and use the older Jet driver.

编辑以下内容:评论

由于已安装32位Access 2007,因此计算机上已经具有32位版本的ACE驱动程序.这实际上消除了安装ACE驱动程序的64位版本的选项,因为如果在计算机上找到32位Office组件,则64位ACE安装程序将中止. (显然,有一种方法可以强制执行第二次安装,但是据报道,在某些情况下它会破坏Office,并且肯定受支持.)

Since you have 32-bit Access 2007 installed you already have a 32-bit version of the ACE driver on the machine. That effectively eliminates the option to install the 64-bit version of the ACE driver because the 64-bit ACE installer will abort if it finds 32-bit Office components on the machine. (There is apparently a way to force the second install but it is reported to break Office in some circumstances and is definitely not supported.)

因此您的选项可以修改为:

So your options can be revised to:

  1. 将Perl脚本作为32位进程运行,或者

  1. Run the Perl script as a 32-bit process, or

删除32位Access 2007,安装64位版本的Access,然后使用64位ACE驱动程序将Perl脚本作为64位进程运行.

Remove 32-bit Access 2007 and install a 64-bit version of Access, then run the Perl script as a 64-bit process using the 64-bit ACE driver.

这篇关于将Perl连接到MS Access的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆