ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie : Oracle to Excel Part 2. RDO or ADO? (https://www.excelbanter.com/excel-programming/336849-newbie-oracle-excel-part-2-rdo-ado.html)

[email protected]

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

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

...


Jean-Yves[_2_]

Newbie : Oracle to Excel Part 2. RDO or ADO?
 
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
wrote in message
oups.com...

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

..





All times are GMT +1. The time now is 09:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com