用于MS Access安装的ODBC [英] ODBC for MS Access Setup

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

问题描述

我正在努力建立ODBC连接,但希望获得一些帮助以确保设置正确.我也希望我可以在编写PHP代码以验证到数据库的连接正常的过程中获得一些帮助.

I'm working on getting an ODBC connection in place but would like some assistance in making sure the setup is correct. I'm also hoping I can get some help in writing the PHP code to verify the connection to the DB is working.

在Windows Server 2008 R2计算机上,我浏览到C:\ Windows \ SysWOW64并运行odbcad32. (这是我开始感到困惑的地方……我看过的大多数页面为此提供了非常基本的信息.)DB是一个MS Access文件.我应该选择哪个选项卡...用户DSN ...系统DSN ...文件DSN?

On a Windows Server 2008 R2 machine, I browse to C:\Windows\SysWOW64 and run odbcad32. (This is where I start getting confused...most pages I've looked at give pretty basic information for this.) The DB is a MS Access file. Which tab do I choose...User DSN...System DSN...File DSN?

选择正确的标签后,输入数据源名称的内容是否正确? (例如,即使文件是"it.accdb",我也可以将数据源命名为"Employees"吗?还是"Employees.accdb"?还是必须与实际文件名匹配?

Once I choose the correct tab, am I correct in entering anything for the Data Source Name? (For instance, even though the file is 'it.accdb', can I put name the data source 'Employees'? 'Employees.accdb'? Or does it have to match the actual file name?

最后,连接到数据库的PHP代码是什么?该数据库当前为D:\ Temp \ IT.accdb.我已经在系统DSN"选项卡中当前配置了ODBC,其数据源名称为"Employees"并指向数据库.我尝试了以下代码:

Finally, what would the PHP code be to connect to the DB? The DB is currently D:\Temp\IT.accdb. I've got the ODBC currently configured in the System DSN tab with a Data Source Name of 'Employees' and pointing to the DB. I've tried the following code:

<?php
$dbName = "Employees";

if (!file_exists($dbName)) {
   die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb,*.accdb)}; DBQ=$dbName; Uid=; Pwd=;");

我试图将$ dbName更改为各种各样的东西,但是我尝试的所有结果都导致找不到数据库文件.

I've tried changing $dbName to be a variety of things but everything I've tried results in not finding the database file.

有人可以帮我吗?

推荐答案

有两种方法可以通过网络访问ODBC数据源.您可以挂载包含数据库的网络驱动器,并为系统用户提供对数据库的读/写访问权限(我不建议这样做).或使用ODBC brigde,例如 OpenLink .

There are two ways to access an ODBC datasource across a network. You can either mount a network drive containing the database, and give the system user read/write access to it (not something I recommend); Or use an ODBC brigde, like OpenLink.

如果要将数据库与PHP代码移至同一服务器,那么我认为

If you want to move the DB to the same server as the PHP code, then I think that this sitepoint guide should be of assistance.

推荐使用后一种方法,也是最简单的方法.为此,您需要在包含数据库的服务器上将ODBC源设置为"System-DSN",并根据需要进行命名. 系统数据库"应选中无",我建议设置用户名和密码.然后安装指向此DSN的ODBC请求代理.
在客户端,您设置了ODBC客户端桥,将其配置为在远程上使用DSN.然后,您需要做的就是在PHP中创建一个DSN字符串,如下所示:

The latter one is the recommended, and easiest way, to go about it. For this you need to set up the ODBC source as a "System-DSN" on the server containing the database, naming it whatever you like. The "system database" should be checked on "none", and I recommend setting up a username and password. Then install the ODBC request broker pointing to this DSN.
On the client side you set up the ODBC client bridge, configure it to use the DSN on the remote. Then all you need to do, is to create a DSN-string like this in PHP:

$dsn = "odbc:dsn_name";

就是这样.

请注意,经纪人确实会稍加注意,但是只要您阅读指南,它就非常简单. OpenLink也有一个试用版,因此您可以弄清楚它是否适合您.为了弄清楚您需要哪些部分,它们还具有一个软件选择向导.

Note that the broker does take a little care to set up, but as long as you read the guides it's pretty straight forward. OpenLink also has a trial version, so that you can figure out whether or not it'll work for you. To figure out which parts you need, they also have a Software selection wizard.

也有其他提供此类软件的提供商,但我只有OpenLink经验.

There are also other providers for this kind of software, but I have only experience with OpenLink.

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

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