Soon after ADO's release, Microsoft created an extension to the
object library called ActiveX Data Objects Extensions, or ADOX.
This library includes most of the DAO features missing from
standard ADO, including objects related to a database's schema.
With ADOX you can easily determine if a database contains a
specific table, view, or query.
To do so, set a reference to Microsoft ADO Ext. for DDL and
Security. For schema purposes, the ADOX consists of a Catalog
object, which contains the object collections that describe the
database, tables and views among them. To test for an existing
table in the Tables collection, you can either iterate through
the collection and check each item's name against the test
string; or you can use our favorite method, as seen in the
following code:
Private Sub Command1_Click()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.3.51;" _
& "Data Source=C:Program FilesMicrosoft Visual StudioVB98Biblio.mdb"
On Error Resume Next
Set tbl = cat.Tables("MyTable")
If tbl Is Nothing Then
MsgBox "MyTable doesn't exist"
Else
MsgBox "MyTable exists"
Set tbl = Nothing
End If
Set cat = Nothing
Set con = Nothing
End Sub
Determine if internal database objects exist
By ElementK Journals, published on 14 Jul 2001
| Filed in
You might also like...
Security forum discussion
-
Best security system for laptop
by maha.k47825 (0 replies)
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
Flask or Django?
by radavid24 (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
Security podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments