Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 4
Default Getting data efficiently

I've written some VBA code that gets data from an Oracle database. So for
each VisitID in the excel sheet starting from C10 it runs a query in a loop
and gets the date of visit ( dated) and puts that next to the visitID. heres
the code

col = "C"
row = 10

cell = col & CStr(row)

Do While Range(cell) < ""

visitID = Range(cell)

sql = "select dated " & _
"from visit v, patient p " & _
"where v.patient_id = p.patient_id " & _
"and visit_id = " & visitID


rs.Open sql

If Not rs.EOF Then

Range(cell).Offset(0, 1) = rs("dated")

Else

Range(cell).Offset(0, 1) = ""

End If

rs.Close

row = row + 1
cell = col & CStr(row)

Loop

So the same query gets compiled and executed for each visitID. This is slow
and there must be a better method to get such data.
any ideas appreciated.

thx


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
Can I use a pivot table with this efficiently? Darren Ingram Excel Discussion (Misc queries) 0 February 24th 09 10:08 AM
Efficiently Generate 88 Chartsheets [email protected] Excel Worksheet Functions 3 July 5th 06 01:53 PM
How to efficiently declare variables Jeff Excel Discussion (Misc queries) 2 June 29th 06 01:56 PM
How to get 500 hyperlink address efficiently? liru Excel Discussion (Misc queries) 4 May 16th 06 03:56 AM
Group and Count Text Data More Efficiently JonOfAllTrades Excel Worksheet Functions 1 March 8th 06 09:40 PM


All times are GMT +1. The time now is 12: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"