VB6 Retrieve the Information You Want
Public oSQLServer As New SQLDMO.SQLServer
Public oDatabase As SQLDMO.Database
Public oTable As SQLDMO.Table
Public oColumn As SQLDMO.Column
Public sDatabaseName As String
Public sTableName As String
Public sColumnName As String


   ' Get all the databases in SQL Server
   Screen.MousePointer = vbHourglass

   oSQLServer.Connect Text_SQLServer.Text, _
      Text_ID.Text, Text_Pwd.Text

   Command1.Enabled = False

   For Each oDatabase In oSQLServer.Databases
      If oDatabase.Status <> SQLDMODBStat_Inaccessible _
         Then
         Form1.List_Databases.AddItem oDatabase.Name
      End If
   Next oDatabase

   Screen.MousePointer = vbDefault
   Unload Form2
   Form2.Hide
   Form1.Show

' Get all the tables for the specified database
If List_Databases.ListIndex >= 0 Then
   sDatabaseName = List_Databases.List( _
      List_Databases.ListIndex)
   Else
      sDatabaseName = oSQLServer.Databases(1).Name
   End If

   List_Tables.Clear
   List_Columns.Clear
   ' Text_Column.Text = vbNullString

   For Each oTable In oSQLServer.Databases( _
      sDatabaseName).Tables
      List_Tables.AddItem oTable.Name
   Next oTable

' Get all the fields for the specified table
If List_Tables.ListIndex >= 0 Then
   sDatabaseName = List_Databases.List( _
      List_Databases.ListIndex)
      sTableName = List_Tables.List(List_Tables.ListIndex)
   Else
      If List_Databases.ListIndex < 0 Then _
         List_Databases.ListIndex = 0
      sDatabaseName = List_Databases.List( _
         List_Databases.ListIndex)

      If List_Tables.ListIndex < 0 Then _
         List_Tables.ListIndex = 0
      sTableName = List_Tables.List(List_Tables.ListIndex)
   End If

   List_Columns.Clear

   For Each oColumn In oSQLServer.Databases( _
      sDatabaseName).Tables(sTableName).Columns
      List_Columns.AddItem oColumn.Name
   Next oColumn

Listing 1 The SQL-DMO's SQLServer object lets you retrieve database, table, and column information by iterating through each collection object. This code, which you place behind the XML generator's logon button, iterates through all the available SQL Server databases. To improve performance, you might want to consider changing the code to load only the databases you are interested in.