Oracle Client and networking components were not found - Excel VBA

╄→гoц情女王★ 提交于 2019-12-12 13:10:44

问题


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:

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


回答1:


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.




回答2:


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

Press Alt + Enter and open the Build section.

I unchecked it and then the app worked perfectly.

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



来源:https://stackoverflow.com/questions/39779100/oracle-client-and-networking-components-were-not-found-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!