Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retreiving the tables names into an Access database
Message
 
To
13/12/2000 19:08:04
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Quebec, Canada
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00453174
Message ID:
00453180
Views:
36
>HI,
>I have an ADO connection to an Access database. Is it possible to go through it to retreive the tables names in it ?

You need to use the OpenSchema method of the connection object:
Public Sub OpenSchemaX()

   Dim cnn1 As ADODB.Connection
   Dim rstSchema As ADODB.Recordset
   Dim strCnn As String
      
   Set cnn1 = New ADODB.Connection
      strCnn = "Provider=sqloledb;" & _
      "Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "
   cnn1.Open strCnn
      
   Set rstSchema = cnn1.OpenSchema(adSchemaTables)
   
   Do Until rstSchema.EOF
      Debug.Print "Table name: " & _
         rstSchema!TABLE_NAME & vbCr & _
         "Table type: " & rstSchema!TABLE_TYPE & vbCr
      rstSchema.MoveNext
   Loop
   rstSchema.Close
   
   cnn1.Close
   
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform