Results 1 to 4 of 4

Thread: ADO and Access Query

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    Using ADO in VB, how do you execute an Access query? I've tried treating it like a stored procedure with no success. Surely Microsoft didn't leave a huge hole like this in one of it's main programming solutions on purpose!

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Can you be more specific?

    If you are trying to get the recordset returned by an existing query in Access, this works for me:
    Code:
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
    
        cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\WINDOWS\Desktop\MyDatabase.mdb"
        cn.Open
        rs.Open "MyQueryName", cn
        
        ' Now rs holds the results of your query
        ' Do what you want with it here
    
        Set rs = Nothing
        Set cn = Nothing
    Does that help?
    ~seaweed

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    That's way too easy, and it also works. Where is this documented? I looked all over the place and couldn't find anything on it. Thanks for your help.

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    I used ADO 2.1 Programmer's Reference by David Sussman, WROX publishing
    ~seaweed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width