I am having a bit of trouble navigating ADOX with multiple catalogs in SQL.
The following code will pull the tables into one list and the fields into another. The problem is the SQL server has 5 different databases in it and this is pulling them all. Can I get this broken down by each DB in the server?
Matt
The following code will pull the tables into one list and the fields into another. The problem is the SQL server has 5 different databases in it and this is pulling them all. Can I get this broken down by each DB in the server?
Matt
Code:
Private Sub Command1_Click()
Dim myConnection As Connection
Dim myCatalog As Catalog
Dim myTable As Table
Dim myColumn As Column
Set myConnection = New Connection
myConnection.ConnectionString = strMainConn
myConnection.Open
Set myCatalog = New Catalog
Set myCatalog.ActiveConnection = myConnection
For Each myTable In myCatalog.Tables
If myTable.Type = "TABLE" Then
List1.AddItem myTable.Name & ", " & myTable.Type
For Each myColumn In myTable.Columns
List2.AddItem " " & myColumn.Name
Next
End If
Next
Set myCatalog = Nothing
myConnection.Close
Set myConnection = Nothing
End Sub