Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

ADO equivalent of DAO 'Database' object

Posted on 2001-07-31
4
Medium Priority
?
415 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 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