PC Review


Reply
Thread Tools Rate Thread

ADO copy from SQL Server into Excel 2003 List Box

 
 
christopher ward
Guest
Posts: n/a
 
      9th Nov 2009

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 With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      9th Nov 2009
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste failed in excel file migrated from Excel 2003 to Excel Handong Chen Microsoft Excel Crashes 1 4th Mar 2010 06:05 PM
server 2000 upgrade to server 2003 file copy error =?Utf-8?B?c29sZGllcjI2NjI=?= Microsoft Windows 2000 Upgrade 2 2nd Jan 2008 03:48 AM
upgrade windows server 2000 to server 2003 File Copy Error =?Utf-8?B?c29sZGllcjI2NjI=?= Microsoft Windows 2000 1 11th Apr 2007 06:28 PM
Excel 2007 - Sharpoint 2003 can't update list on server Michael Price Microsoft Excel Misc 3 26th Feb 2007 03:43 PM
Local copy and Server copy do not match in Outlook 2003 =?Utf-8?B?amFzb24=?= Microsoft Outlook Discussion 1 9th May 2006 12:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:27 AM.