Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I retrieve data from an Oracle db?


I need to create a button in Excel that when clicked will query an
Oracle database using a value stored in cell E1 as a restriction in the
query. Also I need the results of the query to be listed in a range of
cells in the workbook on the same sheet the button exists.

example:

If cell E1 = 10, then I need a button that when pressed runs a query
across an Oracle database;

Select name, number
from Panel
where number = '10'

I'm expecting 30 to 200 names to be returned. I would like these names
from the oracle db to be populated in cells IT4 - It 300.

Thanks,
Dan


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How do I retrieve data from an Oracle db?

drs****** wrote in
:


I need to create a button in Excel that when clicked will query an
Oracle database using a value stored in cell E1 as a restriction in
the query. Also I need the results of the query to be listed in a
range of cells in the workbook on the same sheet the button exists.

example:

If cell E1 = 10, then I need a button that when pressed runs a query
across an Oracle database;

Select name, number
from Panel
where number = '10'

I'm expecting 30 to 200 names to be returned. I would like these names
from the oracle db to be populated in cells IT4 - It 300.

Thanks,
Dan


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from
http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements


You'll most likely want to do this using ADO. Add the button to your
sheet and in the code behind it you'd open the connection & recordset,
then loop through the recordset adding values to cells as you iterate
through.

Private Sub CommandButton1_Click()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim RowCurr As Long
Dim ColCurr As String
Dim ws As Excel.Worksheet

RowCurr = 4
ColCurr = "I"
Set ws = CommandButton1.Parent

cnn.Open YourConnectionStringToOracle
rst.Open YourSqlStatement, cnn

Do Until rst.EOF
ws.Range(colCurr & RowCurr).Value = rst.Fields("YOUR_FIELD").Value
RowCurr = RowCurr +
rst.MoveNext
Loop
rst.Close
cnn.Close
End Sub

--
Andrew Mauer

To reply directly, remove .nospam from address.
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
Imported Oracle Data S. Kissing Excel Discussion (Misc queries) 0 November 16th 07 08:16 PM
ODBC data insert to Oracle renee New Users to Excel 0 October 18th 05 08:37 PM
export data into Oracle table val_petrescu Excel Discussion (Misc queries) 0 May 20th 05 08:20 PM
Retrieving data from Oracle drswanker[_2_] Excel Programming 0 December 8th 03 07:34 PM
Oracle data to excel Kim[_8_] Excel Programming 2 October 21st 03 12:29 PM


All times are GMT +1. The time now is 10:35 AM.

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

About Us

"It's about Microsoft Excel"