ADOX 2.7

Catalog ActiveConnection Property Example (VB)

Setting the ActiveConnection property to a valid, open connection "opens" the catalog. From an open catalog, you can access the schema objects contained within that catalog.

' BeginOpenConnectionVB
Sub OpenConnection()

   Dim cnn As New ADODB.Connection
   Dim cat As New ADOX.Catalog

   cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= c:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind.mdb;"
   Set cat.ActiveConnection = cnn
   Debug.Print cat.Tables(0).Type

End Sub
' EndOpenConnectionVB

Setting the ActiveConnection property to a valid connection string also "opens" the catalog.

' BeginOpenConnection2VB
Sub OpenConnectionWithString()

   Dim cat As New ADOX.Catalog

   cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=c:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind.mdb;"
   Debug.Print cat.Tables(0).Type

End Sub
' EndOpenConnection2VB

See Also

ActiveConnection Property | Catalog Object | Table Object | Tables Collection | Type Property (Table)

© 1998-2001 Microsoft Corporation. All rights reserved.