Solved

ADO equivalent of DAO 'Database' object

Posted on 2001-07-31
4
388 Views
Last Modified: 2013-11-23
Hi,

In the (bad) old days you could easily return the names of tables in a database through the MS Jet Workspace object.

I used to do this if I wanted the user to be able to browse for a specific table in an MS Access database...


**********************************************************
 '-- For MS Access connection
 Private wrkJet As Workspace

 Private myDB as Database
 Private myTbl As TableDef

 '-- Connect
 Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
 Set myDB = wrkJet.OpenDatabase(Database_Path, True)

 '-- Retrieve table names and show to user
 For Each myTbl In myDB.TableDefs
    ' Load to user interface here
 Next

**********************************************************

Although now I successfully use ADO to connect to SQL Server to retrieve record sets, I can not immediately see the equivalent for returning table names from an SQL Server database using the ADO connection & command objects.

Can anyone provide an example please?


Cheers!

0
Comment
Question by:G_Evans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
GeoffKell earned 200 total points
ID: 6337325
Use the OpenSchema method of the Connection object.

In example assume mdbConnection is your connection and rs is a recordset object

Regards
GK


    Set rs = mdbConnection.OpenSchema(adSchemaTables)

    Do Until rs.EOF
        If rs.Fields("TABLE_TYPE").Value = "TABLE" Or rs.Fields("TABLE_TYPE").Value = "VIEW" Then
            Debug.Print rs.Fields("TABLE_NAME").Value
        End If
        rs.MoveNext
    Loop
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6337367
Use ADOX to retrieve this information

Vin
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6337383
Geoff's suggestion of OpenSchema is the better way to go. ADOX adds additional components to be distributed for little benefit if this is all you want to do.
0
 

Author Comment

by:G_Evans
ID: 6337707
Cheers - as I say couldn't find an example of that in the online help - Was giving me a right headache!
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question