更新 Access 链接表以使用 UNC 路径 [英] Update an Access linked table to use a UNC path

查看:32
本文介绍了更新 Access 链接表以使用 UNC 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Access 2010 数据库 A.mdb,其中包含一个表列表,其中一个是链接表,从另一个 Access 数据库 B.mdb 链接到同一个服务器.这些数据库在开发机器xxx.xxx.xxx.xxx上,在我的电脑上映射为R://,然后它们在xxx.xxx.xxx.xxx上在线发布代码>yyy.yyy.yyy.yyy 服务器.

I have an Access 2010 database A.mdb with a list of tables, one of which is a linked table, linked from another Access database B.mdb on the same server. These databases are on a development machine xxx.xxx.xxx.xxx, which is mapped on my computer as R://, and they are afterwards published online on a yyy.yyy.yyy.yyy server.

如果我想在本地处理数据库,我需要更改表的链接.但是,如果我通过文件系统(使用链接表管理器")更改它,链接将变为 R://.... 并且当我查看请求这些数据的 ASP 页面时,它是坏了,因为路径不对.另外,如果我在本地更改链接,它将无法在在线服务器上运行.

If I want to work on the database locally, I need to change the link to the table. But if I change it via filesystem (using the "Linked Table Manager"), the link becomes R://.... and when I look at the ASP page that requests those data, it is broken because the path is wrong. Also, if I change the link locally, it won't work on the online server.

有没有办法以编程方式"更改链接?也就是说,不使用链接表管理器?

Is there a way to change the link "programmatically"? That is, without using the Linked Table Manager?

我搜索了一个答案,但我不是那个专家,我只是明白我必须写一个模块"?宏"?

I searched for an answer, but I am not that expert, I just understood that I have to write a "Module"? "Macro"?

推荐答案

表链接可以是 UNC 路径.例如,假设我有一个指向 \192.168.1.2Public 上的数据库的链接表,该数据库映射到驱动器 P:.如果我启动 VBA 编辑器 (Alt+F11),打开即时窗口 (Ctrl+G) 并输入...

Table links can be UNC paths. For example, say I have a linked table pointing to a database on \192.168.1.2Public which is mapped to drive P:. If I launch the VBA editor (Alt+F11), open the Immediate Window (Ctrl+G) and type...

?CurrentDB.TableDefs("remoteTable").Connect

...它会回来...

;DATABASE=P:B.accdb

...因为我在创建链接时指向驱动器 P:.

...because I pointed to drive P: when I created the link.

现在,如果我创建并运行 VBA 函数...

Now if I create and run the VBA function...

Function linkToUnc()
Dim cdb As DAO.Database
Set cdb = CurrentDb
cdb.TableDefs("remoteTable").Connect = ";DATABASE=\192.168.1.2PublicB.accdb"
cdb.TableDefs("remoteTable").RefreshLink
Set cdb = Nothing
End Function

...链接现在是一个 UNC 路径.

...the link is now a UNC path.

顺便说一下,如果您浏览到网络"、机器名称"、共享名称",您可以在链接表管理器中创建 UNC 链接,但这会给您机器名称(在我的情况下 \PICOPublicB.accdb).

By the way, you can create UNC links in the Linked Table Manager if you browse to "Network", "machine name", "share name", but that will give you the machine name (in my case \PICOPublicB.accdb).

这篇关于更新 Access 链接表以使用 UNC 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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