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

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

问题描述

我有一个Access 2010数据库 A.mdb 与表的列表,其中一个是链接表,从另一个Access数据库的 B.mdb 的链接同一台服务器。这些数据库在开发计算机 xxx.xxx.xxx.xxx ,它映射在我的电脑上是 R于:// ,他们后来在网上一 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.2 \公用\ 被映射到驱动器点:。如果我启动VBA编辑器(替代 + <大骨节病> F11 ),打开立即窗口(控制 + <大骨节病G )和类型...

Table links can be UNC paths. For example, say I have a linked table pointing to a database on \\192.168.1.2\Public\ 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)。连接

...它将返回...

...it will return...

; DATABASE = P:\ B.accdb

...因为我指着开车病人:当我创建的链接

...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.2\Public\B.accdb"
cdb.TableDefs("remoteTable").RefreshLink
Set cdb = Nothing
End Function

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

...the link is now a UNC path.

顺便说一句,你可以创建链接表管理器UNC链接,如果你浏览到网络,计算机名,共享名,但是,这将使你的计算机名(在我的情况 \\ PICO \公用\ B.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 \\PICO\Public\B.accdb).

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

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