将链接表添加到 Access 2003,同时在 MDB 中保留 ODBC 连接信息
我有一个 Access 2003 数据库 MDB,其中所有表都作为 SQL Server 2005 中的链接表存在。MDB 文件包含指向正确 SQL Server 和登录凭据(受信任连接)的所有 ODBC 信息。
我想要做的是将新链接表添加到 MDB 文件,但我不确定如何指定 ODBC 连接信息。当我尝试添加新的链接表时,不断提示我查找或创建 DSN 文件。我不想在每台计算机上创建新的 DSN 条目,而是希望将所有信息存储在 Access MDB 文件本身中。
在现有数据库中,我可以将“鼠标悬停”在表名称上,并以工具提示形式查看 ODBC 连接信息。我需要做的就是使用相同的连接信息添加另一个链接表。
我确实可以访问表链接到的 SQL Server。我已经创建了我想要添加的新表。我只需要找到一种链接到它的方法。
I have an Access 2003 database MDB where all of the tables exist as linked tables within SQL Server 2005. The MDB file contains all of the ODBC information that points to the correct SQL Server and log-on credentials (trusted connection).
What I would like to do is add a new linked table to the MDB file however I am not sure how to go about specifying the ODBC connection information. When I try to add a new linked table I keep getting prompted to locate or create a DSN file. I don't want to have to create a new DSN entry on every machine, rather I would like all that information stored within the Access MDB file itself.
In the existing database I can "hover" over the table names and see the ODBC connection info as a tool-tip. All I need to do is add another linked table using the same connection information.
I do have access to the SQL Server where the tables are linked to,. I have already created the new table I wanted to add. I just need to find a way to link to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就其价值而言,我很懒。我在我的开发机器上保留了一个 DSN,并用它来创建新的链接表。然后我运行 Doug Steele 的代码将链接转换为 dsnless 连接,然后再分发前端到最终用户。
For what it's worth, I'm lazy. I keep a DSN on my development machine, and use it to create new linked tables. I then run Doug Steele's code to convert the links to dsnless connections before distribution of the front end to the end users.
您可以使用现有表中的连接字符串,也可以执行以下操作:
有一些方法用于连接表:
如果表没有唯一索引,这将产生一个消息框
You can use the connection string from an existing table, or you can do something like:
There are a few was to connect a table:
This will produce a message box if the table does not have a unique index
我能够成功添加表格,并想在此处详细说明步骤。
然后我在代码模块中创建了以下子例程。它实质上循环访问 Access 中具有 ODBC 连接的所有表,并将正确的 ODBC 连接信息设置到表定义中。您可以删除之前创建的 DSN,因为不再需要它。
注意...为了执行上述子例程,我只需将其名称输入到访问代码模块内的“立即”窗口中。您还可以创建一个执行此例程的宏,然后每当您创建新表时都可以运行该宏。
感谢“Remou”的解答和帮助!
PS 如果您对连接字符串中的
APP=
及其用途感兴趣,请查看本文。 http://johnnycoder.com/blog/2006 /10/24/利用应用程序名称/I was able to add the table successfully and wanted to detail the steps here.
I then created the following sub routine in the code module. It essentially loops through all your tables in Access that have ODBC connections and sets the proper ODBC connection info into the Table definitions. You can delete the DSN you created previously as it is no longer needed.
NOTE ... To execute the above SubRoutine I just typed in it's name into the "immediate" windows within the Access code module. You could also create a macro that executes this routine and then whenever you create a new table you could just run the macro.
Thanks to "Remou" for his answer and assistance!
P.S. If you are interested in
APP=<APP NAME>
in the connection string and what it is for check out this article. http://johnnycoder.com/blog/2006/10/24/take-advantage-of-application-name/