+ Reply to Thread
Results 1 to 4 of 4

How to connect Excel VBA to Oracle Database to get data.

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Viet Nam
    MS-Off Ver
    Excel 2003
    Posts
    3

    How to connect Excel VBA to Oracle Database to get data.

    Hi All.
    I want to use Excel VBA to connect to oracle Database to get Data.
    Here is the code

    Const PMCalculate = "192.168.2.IP" '"ServerName" ' Server hosting the Oracle db
    Const DBNAME = "NMS" '"DatabaseName"
    Const ORACLE_USER_NAME$ = "user"
    Const ORACLE_PASSWORD$ = "pass"
    Const port = "1521"
    Sub ConnectTOOracle()

    Dim oRs As ADODB.Recordset
    Dim oCon As ADODB.Connection
    Set oCon = New ADODB.Connection

    Dim mtxData As Variant
    Dim strConOracle As String

    strConOracle = "Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) "
    strConOracle = strConOracle & "(HOST=" & PMCalculate & ")(PORT=" & port & "))(CONNECT_DATA=(SERVICE_NAME=" & DBNAME
    strConOracle = strConOracle & "))); uid=" & ORACLE_USER_NAME & " ;pwd=" & ORACLE_PASSWORD & ";"




    oCon.Open strConOracle



    'Cleanup in the end
    Set oRs = Nothing
    Set oConOracle = Nothing

    End Sub


    And the error
    1.jpg

  2. #2
    Registered User
    Join Date
    06-12-2012
    Location
    Viet Nam
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to connect Excel VBA to Oracle Database to get data.

    Please help me.

  3. #3
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: How to connect Excel VBA to Oracle Database to get data.

    You don't have an ODBC driver for oracle installed. Won't work without one. There's 2, 1 released by Microsoft that never got updated to 64bit and hasn't been supported for 15 years (that the company I'm currently on contract for is still using....) and one released by Oracle themselves. Google Oracle ODBC driver.

  4. #4
    Registered User
    Join Date
    06-12-2012
    Location
    Viet Nam
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to connect Excel VBA to Oracle Database to get data.

    Quote Originally Posted by BellyGas View Post
    You don't have an ODBC driver for oracle installed. Won't work without one. There's 2, 1 released by Microsoft that never got updated to 64bit and hasn't been supported for 15 years (that the company I'm currently on contract for is still using....) and one released by Oracle themselves. Google Oracle ODBC driver.
    I have tried many search, many instruction but still fail
    Last edited by hmanhha; 08-23-2017 at 12:23 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to connect to an Oracle Database, run a script/get external data
    By thisguy4000 in forum Access Tables & Databases
    Replies: 3
    Last Post: 08-19-2014, 05:58 AM
  2. Connect to Oracle database on server. x64 Windows 7
    By steve87bg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2013, 08:54 AM
  3. [SOLVED] code which will connect to Oracle DataBase
    By sawoodalam1989 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2013, 11:47 PM
  4. [SOLVED] How to get data from Oracle Database to Excel?
    By David Willis in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-07-2011, 10:44 AM
  5. Connect to oracle and fetch the data
    By ashish4422 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-19-2008, 09:54 AM
  6. Connect to Oracle database using ODBC when opening worksheet
    By oteixeira in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2007, 01:20 AM
  7. [SOLVED] Connect to Oracle using Microsoft ODBC for Oracle
    By Kent in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2006, 11:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1