OleDB Data provider can not be found VBA/Excel

后端 未结 2 1931
情歌与酒
情歌与酒 2021-01-13 06:33

I am almost not familiar with VBA (have had some courses back at school and that\'s it). Now I need to connect to Oracle database (which is running on remote server) from Ex

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 07:06

    32-bit OS

    I managed to get this working on Windows XP virtual machine by downloading oracle OLEDB provider from Oracle official website Oracle10g Provider for OLE DB Version 10.1.0.4.0. Current working link OLEDB for older OS (32 - bit)

    But be aware it will replace JDK and JRE to lower version (It can be prevented by playing with the configuration xml - products.xml - I did not have enough of mental health potion, so I did full install instead). Afterwards you need to delete reference in environment variables as it may effect other programs. After installation, I registered OraOLEDBxx.dll with regsvc32

    I was connecting to oracle db 11G with excel 2003. :)

    Connection string

    I had to enable extensions (ActiveX Data Object and record libraries). My function returning connection was:

    Public Function connectToDb(provider As String, host As String, sid As String, user As String, pwd As String, db As String) As ADODB.Connection
    Dim conn As ADODB.Connection
    Dim dbConnectStr As String
    
        Set conn = New ADODB.Connection
        If provider = "Oracle" Then
            dbConnectStr = "Provider=OraOLEDB.Oracle;Data Source=" & host & ":1521/" & sid & ";User Id=" & user & ";Password=" & pwd & ";"
        Else
    
        End If
        conn.ConnectionString = dbConnectStr
        conn.Open
        Set connectToDb = conn
    End Function
    

    64-bit OS but 32-bit Office

    When our VMs migrated to 64-bit Windows 7 with Excel 2010. Make sure you will download ODAC - Oracle Data Access Components - for right -bit version of your excel installation because I had 32-bit excel installed and thought it was 64-bit (as windows is 64-bit) so I was giving birth trying to get this working with 64-bit ODAC version. Afterwards I did download 32-bit version and it works just as before. For installation just follow install instructions included in downloaded archive folder.

    Current working links for ODAC on Oracle website

提交回复
热议问题