无法使用 MS Access2007 访问 ODBC DB
我在 Access 中通过 ODBC 访问 Oracle 数据库时遇到问题,希望有人提供一些建议。我花了相当长的时间试图找到解决方案,但没有出现任何有用的结果。
我在 ODBC 中设置了一个访问 Oracle 9 数据库的连接。我可以使用 ODBC 管理员的“测试”选项并收到“测试成功”消息。我还可以使用 SQL*PLUS 连接到数据库。但是,当我尝试在 Access 2007 中创建新的链接表并使用 ODBC 选项时,在尝试连接时出现以下错误:
ODBC--调用失败。
[Oracle][ODBC][Ora]ORA-12154: TNS: 无法解析服务名称 (#12154)[Microsoft][ODBC Driver Manager]驱动程序的 SQLSetConnectAttr 失败 IM006 0 [Microsoft][ODBC Driver Manager]驱动程序的 SQLSetConnectAttr 失败 (#0)
我知道 TNS 查找正在工作,因为 ODBC 管理工具与 tnsping 一样工作。问题是,为什么在Access之外可以工作,而Access却不行呢?
编辑(2012-02-22 15:05): 刚刚在另一台电脑上尝试,虽然另一个用户登录并且连接对他们有效,但还是发生了同样的事情,所以它似乎链接到我的 WinXP 配置文件。这有帮助吗?
任何建议将不胜感激。
BBz
I'm having problems accessing an Oracle database via ODBC in Access and hope someone has some advice. I've spent a fair time trying to find a solution, but nothing useful has come up.
I have a connection setup in ODBC that access an Oracle 9 database. I can use the Test option on ODBC administrator and receive a Test Successful message. I can also connect to the DB using SQL*PLUS. However, when I try to create a new linked table in Access 2007 and use the ODBC option, I get the following error when it tries to connect:
ODBC--Call failed.
[Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve service name
(#12154)[Microsoft][ODBC Driver Manager]Driver's SQLSetConnectAttr failed IM006 0 [Microsoft][ODBC Driver Manager]Driver's SQLSetConnectAttr failed (#0)
I know the TNS lookup is working because ODBC Admin tool works as does tnsping. The question is, why does it work outside Access but Access can't do it?
EDIT (2012-02-22 15:05): Just tried on a different PC and the same thing occurs, although another user logged in and the connection worked for them, so it appears to be linked to my WinXP profile. Does this help any?
Any advice would be greatly appreciated.
BBz
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经解决了这个问题,但需要一些挖掘。使用 Sysinternals 的进程监视器,我发现 Access 在我的配置文件的“我的文档”文件夹中找到了一个 sqlnet.ora 文件,并且优先使用该文件而不是全局 tnsnames.ora 文件。
我们之前禁用了 sqlnet.ora(在 Oracle 文件夹中重命名了该文件),但 Access 显然会检查其他位置是否有该文件。我已重命名该文件,现在可以按预期通过 ODBC 访问数据库。
您可以学到有趣的东西!
希望有一天有人会发现这很有用。
感谢您的阅读
BBz
I think I've resolved the issue, but it took some digging. Using Process Monitor from Sysinternals, I discovered that Access had found a sqlnet.ora file in the "My Documents" folder of my profile and was using this in preference to the global tnsnames.ora file.
We had previously disabled sqlnet.ora (renamed the file in the Oracle folder) but Access obvisouly checks other locations for it. I've renamed the file and can now access the DB as expected via ODBC.
Interesting what you can learn!
Hope somebody finds this useful one day.
Thanks for reading
BBz