View Single Post
  #3 (permalink)  
Old February 4th, 2004, 07:06 PM
timparrott timparrott is offline
Registered User
Join Date: Feb 2004
Location: slough, berks, United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

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.
Reply With Quote