Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default ADO copy from SQL Server into Excel 2003 List Box


Dear Experts

I am trying to execute some very simple sql from vba. The sql is

USE master;
SELECT NAME FROM sysdatabases

I want to then place the results in a list box on a vba form

To do this I am looking at recordsets and ado where I cannot find a decent
documented method i can work with. So far I have created


soucon = "Provider=" & Master.TextBox22.Value & ";Data Source=" &
Master.TextBox23.Value _
& ";Initial Catalog=" & Master.TextBox24.Value & ";User id=" &
Master.TextBox25.Value _
& ";Password=" & Master.TextBox26.Value

Set ConSource = CreateObject("ADODB.Connection")
ConSource.Open soucon

which i believe works and connects to Master - how do i now create a
recordset and populate my list box is my question ?

If you respond thank you for your time and efforts as always


kind regards

--
C Ward
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default ADO copy from SQL Server into Excel 2003 List Box

dim rs as ADODB.recordset
dim sql as string

sql = "USE master; SELECT NAME FROM sysdatabases"
set rs = consource.execute(sql,,1)

do while not rs.eof
'rs(0) will be the current NAME, do whatever you want with it
rs.movenext
loop

"christopher ward" wrote:

Dear Experts

I am trying to execute some very simple sql from vba. The sql is

USE master;
SELECT NAME FROM sysdatabases

I want to then place the results in a list box on a vba form

To do this I am looking at recordsets and ado where I cannot find a decent
documented method i can work with. So far I have created


soucon = "Provider=" & Master.TextBox22.Value & ";Data Source=" &
Master.TextBox23.Value _
& ";Initial Catalog=" & Master.TextBox24.Value & ";User id=" &
Master.TextBox25.Value _
& ";Password=" & Master.TextBox26.Value

Set ConSource = CreateObject("ADODB.Connection")
ConSource.Open soucon

which i believe works and connects to Master - how do i now create a
recordset and populate my list box is my question ?

If you respond thank you for your time and efforts as always


kind regards

--
C Ward

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
Question for MVP - install Excel 2003 on MS Server 2003 WCM Setting up and Configuration of Excel 4 February 13th 08 06:59 PM
Excel 2007 - Sharpoint 2003 can't update list on server Michael Price Excel Discussion (Misc queries) 3 February 26th 07 03:43 PM
Excel 2003 Error Cannot Locate the Internet Server or Proxy Server Seabee Excel Discussion (Misc queries) 0 November 20th 05 12:03 AM
Excel 2003 Database Driver Visual FoxPro 7 on Server 2003. Cindy Winegarden Excel Discussion (Misc queries) 0 November 28th 04 12:07 AM
Excel 2003 .net, sql server rishineedsajob Excel Programming 3 April 20th 04 10:49 AM


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