Private Sub DisplayInfo()
Dim oRsTables As ADODB.Recordset Dim oRsFields As ADODB.Recordset Dim oCnn As New
ADODB.Connection
' change this to your SQL Server or Access DB. Dim sCnn As String: sCnn =
"Provider=SQLOLEDB.1;" & _ "Integrated Security=SSPI;" & _ "Persist Security
Info=False;" & _ "Initial Catalog=Northwind;" & _ "Data Source=BENDER"
With oCnn .ConnectionString = sCnn .Open
Set oRsTables = .OpenSchema(adSchemaTables)
Do While Not oRsTables.EOF If oRsTables("TABLE_TYPE").Value = "TABLE" Then
Debug.Print "Table: " & oRsTables("TABLE_NAME").Value Set oRsFields =
.OpenSchema(adSchemaColumns, _ Array(Empty, Empty,
oRsTables("TABLE_NAME").Value, Empty)) Do While Not oRsFields.EOF Debug.Print
" Column: " & oRsFields("COLUMN_NAME").Value oRsFields.MoveNext Loop
Debug.Print End If oRsTables.MoveNext Loop End With
End Sub