Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 21st, 2004, 01:07 PM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?


[]´s

 
Old January 21st, 2004, 01:18 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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



Sal
 
Old February 4th, 2004, 07:06 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to oracle database in struts Manvi Struts 3 August 7th, 2006 10:53 PM
creating SQL 2000 veiws on oracle database Shwetha SQL Server 2000 1 June 30th, 2006 06:30 AM
Connecting Oracle Database with an ASP page krisvamshi Oracle ASP 3 November 14th, 2004 05:56 PM
Exception connecting to Oracle Database with JDBC celia05es Java Databases 1 March 31st, 2004 04:42 AM
Connecting an oracle database kelitu Oracle 0 September 4th, 2003 09:18 AM





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