Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Returning Data From ADO

Historically, I've built reports in Excel using Microsoft Query to grab data
off remote SQL servers and build various graphs and things. However, I was
getting a little frustrated with some of aspects of Microsoft Query, so I
started Googling and discovered that, with a little extra elbow grease, you
can pull data using something called ADO and not only can you make the SQL
cleaner, it apparently runs faster.

The problem I'm having is finding a decent tutorial to introduce this
concept. I keep finding blocks of VB code, but with no instruction about how
to fit this VB into spreadsheets. All I'm trying to do is mimic the
functionality of Microsoft Query really and I'm not having much luck.

Does anybody know any good resources that can explain this process a little
better?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Returning Data From ADO

Hi, I did lots of rooting around for this and eventually worked it out for
myself.

1. In your VB window go to tools/references and tick "Microsoft ActiveX Data
Objects 2.X Library"
2. The following code is then the basis for running a query:

Sub Demo()

Dim c As ADODB.Connection
Dim rs As ADODB.Recordset
Dim s As String

Set c = New ADODB.Connection
c.Open "Insert Connection String Here"

s = "SQL Select Statement of your choice"

Set rs = c.Execute(s, , 1)

do until rs.eof
'Do something with your results
rs.movenext
loop

rs.close

c.Close

End Sub

That should get you in the right direction - the online help for
adodb.recordsets has lots of help too.

Sam


"thefonz37" wrote:

Historically, I've built reports in Excel using Microsoft Query to grab data
off remote SQL servers and build various graphs and things. However, I was
getting a little frustrated with some of aspects of Microsoft Query, so I
started Googling and discovered that, with a little extra elbow grease, you
can pull data using something called ADO and not only can you make the SQL
cleaner, it apparently runs faster.

The problem I'm having is finding a decent tutorial to introduce this
concept. I keep finding blocks of VB code, but with no instruction about how
to fit this VB into spreadsheets. All I'm trying to do is mimic the
functionality of Microsoft Query really and I'm not having much luck.

Does anybody know any good resources that can explain this process a little
better?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Returning Data From ADO

I fnd the help in Access VBA to be pretty good. Do a search in Access VBA
help for ADO.


These are the extra things you need to do in excel to use the Access macro
code

1) Add a reference to the access library in Excel VBA from menu

tools - References - Microsoft Access Library 11.0 object Library.

You also may need
tools - References - Microsoft ActiveX Data object 2.8 library

2) Create and Access object in Excel VBA

set obj = CreateObject("Access.Application")

3) Use the object above in the code you find for Access VBA.




"thefonz37" wrote:

Historically, I've built reports in Excel using Microsoft Query to grab data
off remote SQL servers and build various graphs and things. However, I was
getting a little frustrated with some of aspects of Microsoft Query, so I
started Googling and discovered that, with a little extra elbow grease, you
can pull data using something called ADO and not only can you make the SQL
cleaner, it apparently runs faster.

The problem I'm having is finding a decent tutorial to introduce this
concept. I keep finding blocks of VB code, but with no instruction about how
to fit this VB into spreadsheets. All I'm trying to do is mimic the
functionality of Microsoft Query really and I'm not having much luck.

Does anybody know any good resources that can explain this process a little
better?

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
Sumproduct not returning data Trish Smith Excel Worksheet Functions 4 October 28th 08 07:07 PM
Returning data Newfie809 Excel Worksheet Functions 3 August 22nd 08 09:23 PM
Returning Data Newfie809 Excel Worksheet Functions 1 August 22nd 08 09:22 PM
Returning data nir020 Excel Worksheet Functions 2 January 30th 07 01:53 PM
Returning Data From Access Mark[_34_] Excel Programming 1 January 26th 04 02:51 PM


All times are GMT +1. The time now is 11:07 AM.

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"