Search code examples
oraclewindows-7vb6windows-7-x64

How can I get the "Microsoft ODBC for Oracle" driver to work in Windows 7


I have an old VB6 app that I need to get working on a Windows 7 x64 workstation (at least for a little while).

It's failing on me when I try to connect to my test database (Oracle 10gR2). I get an "ORA-06413: Connection not open error."

Now, I recognise that the "Microsoft ODBC for Oracle" driver is deprecated because it doesn't play nice with newer versions of Oracle. It seems to work fine with the same database on an XP box I have access to.

I also see that the driver seems to still exist on Windows 7 x64 (at least when I look at the 32 bit version of the ODBC data Source Administrator tool: c:\Windows\SysWOW64\odbcad32.exe in the Drivers tab.

On the XP box, it doesn't seem to matter what I see up for an ODBC connection, it seems to bypass any sort of predefined connection.

Attached is the relevant code. Is there any way to make this work in Win7x64?

Global g_sConnectionString As String
Global g_oConn As ADODB.Connection

Public Sub CreateOracleConn()
    Err.Clear
    On Error Goto ConnectionError

    g_sConnectionString = "Driver={Microsoft ODBC for Oracle}; " _
                            & "SERVER=" & "MyHost" _
                            & ";UID=" & "MyUserID" _
                            & ";PWD=" & "MyPassword & ";"

    Set g_oConn = New ADODB.Connection
    g_oConn.Open g_sConnectionString  '<-- fails here

    Exit Sub

ConnectionError:
    If Err.Number <> 0 Then
        'Clean up from the error
    End If
End Sub

Solution

  • The problem entirely relates to where Visual Basic 6 is installed. By default it is installed in C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE

    If you change its location to something like: C:\ProgramFilesX86\Microsoft Visual Studio\VB98\VB6.EXE

    It runs properly.