Newbie : Oracle to Excel Part 2. RDO or ADO?


R

richmarin

I am using Excel 2002.

Thanks for the previous reply. I wanted to do the following. I wanted
to pass an SQL statement to Oracle. For example, here is a pretend SQL
statement

Select customer id, name from customer table where state = "NY"

Then use RDO or ADO to get the data, and place it into Excel.

How should I do this. Do I still create an ODBC link? Can I still pass
SQL statements using ODBC?

Thanking you all in advance

Rich

...
 
Ad

Advertisements

J

Jean-Yves

Hi Rich,

Have a try

Sub test()
Dim connMdb As ADODB.Connection
Dim recMdb As ADODB.Recordset
Dim strStatus As String

Set connMdb = New ADODB.Connection
Set recMdb = New ADODB.Recordset
"open a connection to the DB
connMdb.conn.Open "Provider=MSDAORA;Data Source=theDB", "userID", "password"
recMdb.Open "SELECT [customer id], name FROM customer WHERE state = 'NY' ;",
connMdb, adOpenForwardOnly,
adLockOptimistic
Do while recMdb.EOF = False
debug.print recmdb.fields("customer id").value & " " &
recmdb.fields("name").value
Loop
recMdb.Close
Next cl

connMdb.Close
Set recMdb = Nothing
Set connMdb = Nothing
End Sub

Regards
Jean-Yves
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top