Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Connect to Oracle Database through ODBC with VBA

Hi

Could anyone give me some pointers as to how I can, through VBA,
connect to an oracle database, run a query on the database, and then
return one column of the results from the query to populate a listbox
on a VBA Userform in an Excel Spreadsheet?

Can I use DAO to connect to the database? and somehow place the
queryresults into a recordset which can then be placed into the
listbox.

Any help would be be appreciated.

Regards

J
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Connect to Oracle Database through ODBC with VBA

Cnn="DSN=mysysdsn;UID=mydb;PWD=mypwd"
Sql="Select distinct(mycol) as mycol from mytable
Set ADORS=CreateObject("ADODB.RecordSet"
ADORS.Open Sql,Cn

MyValues = ADORS.GetRow

MyValues now is a array (0 based): you can loop through lbound(myValues) to ubound(myValues) to populate the list box

NOTE: The Cnn and Sql strings will be specific to your PC/Database: change these as appropriate. If you needed to, you can use the MSDAORA provider instead of the DSN.
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
link ODBC connection to an Oracle database Richard Excel Discussion (Misc queries) 1 November 5th 06 05:29 PM
ODBC data insert to Oracle renee New Users to Excel 0 October 18th 05 08:37 PM
Oracle odbc Slinjger Excel Discussion (Misc queries) 1 July 3rd 05 04:35 PM
Problems Using MS Oracle ODBC with Excel news.aristotle.net Excel Programming 3 April 2nd 04 04:41 PM
connect to an oracle server Bill Li Excel Programming 0 August 14th 03 04:31 AM


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