Connecting Excel VBA to oracle DB using 'ODBC'

China☆狼群 提交于 2019-12-01 10:03:54

问题


Basically i work in a software company. My client has a Oracle database.

I do access that database through SQL Developer.We have a virtual desktop too -inside which we have all client applications,SQL Plus etc..!!

Now one other person in my team has created a excel macro in which if you give your username password and your SQL query, it will connect to the oracle database and fetch the records for you and will save it in an excel sheet in the virtual desktop itself.

Now i want to do something similar but i am not able to fins how i connect my excel VBA to Database. As his macro is able to connect to the database i am pretty sure all necesaary drivers are installed in our virtual machine(desktop).

I can see "Oracle - OraClient11g_home1" in All programs in my virtual machine.I can see SQL plus and all those apps. Giving all these details because i read in other posts that these things may be required to connect to DB.

In SQL Devloper if i go to connection properties it shows me the Network Alias name as "xxxxxx"(I have replaced by xx).Connection type as 'TNS' and role as 'Default'.I know my username and password.

Note: In Excel when i go to new connect database option, i dont see Oracle Driver at all:( I can see only "Microsoft Driver for Oracle".

These are all the details i know . Can someone help me with connecting to Database.Once someone can help me do it rest everything i can do in my macro.:)


回答1:


I just tested it following these steps:

  1. Excel > Data > Get External Data > From Other Sources > From Data Connection Wizard
  2. From Data Connection Wizard, select "Other/Advanced" and click Next
  3. On the Connection tab, create new connection string by click on Build
  4. On Machine Data Source tab, click New
  5. Select Oracle driver

  1. Enter corret "TNS Service Name" and your user id. Click test connection and enter your password.


来源:https://stackoverflow.com/questions/37339682/connecting-excel-vba-to-oracle-db-using-odbc

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