未找到 Oracle 客户端和网络组件 - Excel VBA

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39779100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 11:20:54  来源:igfitidea点击:

Oracle Client and networking components were not found - Excel VBA

excelvbaoracleoracleclient

提问by jDave1984

I'm trying to connect to an Oracle DB through Excel. I have installed the Instant Client from Oracle on my machine, but am getting this message when I run this code:

我正在尝试通过 Excel 连接到 Oracle DB。我已经在我的机器上安装了来自 Oracle 的 Instant Client,但是当我运行此代码时收到此消息:

Sub testing()


    Dim myConn As Connection: Set myConn = New Connection
    Dim mySet As Recordset: Set mySet = New Recordset
    Dim CONNSTRING As String
    CONNSTRING = "Driver={Microsoft ODBC for Oracle}; " & _
                "CONNECTSTRING=(DESCRIPTION=" & _
                "(ADDRESS=(PROTOCOL=TCP)" & _
                "(HOST=xxxxxx.xxx.xxxxxxxxxxx.com)(PORT=1524))" & _
                "(CONNECT_DATA=(SERVICE_NAME=dev))); uid=xxxxxxx; pwd=xxxxxxxxxxx;"

    myConn.Open CONNSTRING
    mySet.Open "SELECT * FROM apps.ap_invoice_lines_interface", myConn, adOpenStatic, adLockBatchOptimistic, adCmdTable

    Sheet1.Range("A1").CopyFromRecordset mySet

    mySet.Close
    myConn.Close

End Sub

The message I am getting is

我收到的消息是

The Oracle(tm) client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3 (or greater) client software installation. You will be unable to use this driver until these components have been installed

未找到 Oracle(tm) 客户端和网络组件。这些组件由 Oracle Corporation 提供,是 Oracle 7.3(或更高版本)客户端软件安装的一部分。在安装这些组件之前,您将无法使用此驱动程序

回答by EdStevens

I see this error frequently when our desktop support team installs the wrong Oracle client. If your application (Excel, in this case) is 32-bit, then you also need to be using 32-bit ODBC and 32-bit Oracle client. It doesn't matter that your OS or hardware is 64-bit. What matters is the application. And it seems that most MS Office installations are 32-bit, even when installed on 64-bit Windows.

当我们的桌面支持团队安装错误的 Oracle 客户端时,我经常看到此错误。如果您的应用程序(在本例中为 Excel)是 32 位的,那么您还需要使用 32 位 ODBC 和 32 位 Oracle 客户端。您的操作系统或硬件是 64 位并不重要。重要的是应用程序。似乎大多数 MS Office 安装都是 32 位的,即使安装在 64 位 Windows 上也是如此。

回答by Leniel Maccaferri

In my case, the Console project in Visual Studio had Prefer 32 bitcheck-marked in its Properties.

就我而言,Visual Studio 中的 Console 项目Prefer 32 bit在其属性中进行了复选标记。

Press Alt+ Enterand open the Build section.

Alt+Enter并打开“构建”部分。

I unchecked it and then the app worked perfectly.

我取消选中它,然后该应用程序运行良好。

By the way: I had installed Oracle client 64 bit.

顺便说一句:我已经安装了 64 位的 Oracle 客户端。

enter image description here

在此处输入图片说明