p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Excel VBA (http://p2p.wrox.com/forumdisplay.php?f=79)
-   -   Creating and connecting in a Oracle Database (http://p2p.wrox.com/showthread.php?t=8411)

cutovoi January 21st, 2004 01:07 PM

Creating and connecting in a Oracle Database
Hi for all
I would like to know how can I create a connection with a Oracle Database, creating the ODBC´s and all necessary things to do this.
Please, can anyone help me?


sal January 21st, 2004 01:18 PM

What are you trying to do? you could write some code, create a recordset and drop the data to excel via code.


timparrott February 4th, 2004 07:06 PM

The best option is to use ADO. (Active Data Objects)

Set up an ODBC DSN to your Oracle TNS name and then use the oracle ODBC test to check that you can connect to the data base. Type in "Select Sysdate from Dual" and execute it. It will return the current date and time.

the general steps in VB are to

a. Establish a connection to the Oracle Database.
b. Create a recordset in memory
c. Process each field in each record and write it to a cell on a spreadsheet.
d. Close the recordset and connection

Easy to say but how to start.

The quickest way is to use MS query. This is not ADO but will give you some idea of what is required.

Open a new work book and start by recording a macro.

Go to Data, Get External Data, New Data base query and follow the steps in the wizard. Return the data to the worksheet and then stop recording.

It will have created the connection string and the SQL in MS Query format.

In the end you will probably want to create your own SQL on the fly and pass run time parameters. You can do this with the MS query option but you would be better off reading the ADO help, the only key bit missing in the help is the connection string which has been created for you in the Macro.

All times are GMT -4. The time now is 08:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.