Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Retrieve data from Oracle Database

Hi,

I need an code example for retrieve data from a table in oracle database via
"Microsoft ODBC for oracle" driver or something similar...

Many thanks!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Retrieve data from Oracle Database

The following example uses ADO with late binding, you need to replace the
"my" arguments in the connection string with yours:

Sub Oracle_Test()

Dim adoCN As Object
Dim adoRS As Object
Dim rngCell As Range
Dim lngX As Long

Set adoCN = VBA.CreateObject("ADODB.Connection")
adoCN.CursorLocation = 3
adoCN.ConnectionString = "PROVIDER=MSDASQL.1;DRIVER={ORACLE ODBC
DRIVER};SERVER=myInstanceName;DBQ=myDBQName;UID=my UserID;PWD=myPassword;"
adoCN.CommandTimeout = 0 'NO TIMEOUT
adoCN.Open
Set adoRS = VBA.CreateObject("ADODB.Recordset")
adoRS.MaxRecords = 0 '0 = ALL RECORDS
Set adoRS = adoCN.Execute("SELECT * FROM DUAL")

For lngX = 1 To adoRS.Fields.Count
ActiveCell.Offset(0, lngX - 1).Value = adoRS.Fields(lngX - 1).Name
Next lngX
ActiveCell.Offset(1, 0).Select

ActiveCell.CopyFromRecordset adoRS
adoRS.Close
Set adoRS = Nothing

End Sub

HTH

"Carlos Pérez" wrote:

Hi,

I need an code example for retrieve data from a table in oracle database via
"Microsoft ODBC for oracle" driver or something similar...

Many thanks!




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve data from excel database Vanya Noble Excel Discussion (Misc queries) 0 November 12th 09 12:51 AM
conection with Oracle database ashishprem[_19_] Excel Programming 3 May 25th 06 05:57 AM
How to get data from Oracle Database to Excel? David Willis New Users to Excel 1 March 31st 06 01:57 PM
Retrieve Data from SQL database Programatically using Excel VBA ebferro Excel Programming 0 December 2nd 05 04:26 PM
How do I retrieve data from an Oracle db? drswanker[_3_] Excel Programming 1 January 16th 04 08:00 PM


All times are GMT +1. The time now is 08:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"