VERSION 4.00
Begin VB.MDIForm SQLPDBA 
   BackColor       =   &H8000000C&
   Caption         =   "Microsoft SQL Server - sample "
   ClientHeight    =   5790
   ClientLeft      =   1185
   ClientTop       =   1815
   ClientWidth     =   7905
   Height          =   6480
   Icon            =   "SQLPDBA.frx":0000
   Left            =   1125
   LinkTopic       =   "MDIForm1"
   Top             =   1185
   Width           =   8025
   Begin Threed.SSPanel StatusBar 
      Align           =   2  'Align Bottom
      Height          =   315
      Left            =   0
      TabIndex        =   2
      Top             =   5475
      Width           =   7905
      _version        =   65536
      _extentx        =   13944
      _extenty        =   556
      _stockprops     =   15
      caption         =   "  No Server Connected"
      backcolor       =   12632256
      bevelouter      =   1
      alignment       =   1
   End
   Begin Threed.SSPanel ToolBar 
      Align           =   1  'Align Top
      Height          =   435
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7905
      _version        =   65536
      _extentx        =   13944
      _extenty        =   767
      _stockprops     =   15
      backcolor       =   12632256
      bevelouter      =   0
      outline         =   -1  'True
      Begin Threed.SSCommand bDevice 
         Height          =   375
         Left            =   1200
         TabIndex        =   4
         Top             =   30
         Width           =   375
         _version        =   65536
         _extentx        =   661
         _extenty        =   661
         _stockprops     =   78
         forecolor       =   8421504
         enabled         =   0   'False
         bevelwidth      =   1
         roundedcorners  =   0   'False
         outline         =   0   'False
         picture         =   "SQLPDBA.frx":030A
      End
      Begin Threed.SSCommand bDB 
         Height          =   375
         Left            =   810
         TabIndex        =   3
         Top             =   30
         Width           =   375
         _version        =   65536
         _extentx        =   661
         _extenty        =   661
         _stockprops     =   78
         enabled         =   0   'False
         bevelwidth      =   1
         roundedcorners  =   0   'False
         outline         =   0   'False
         picture         =   "SQLPDBA.frx":085C
      End
      Begin Threed.SSCommand bConnect 
         Height          =   375
         Left            =   60
         TabIndex        =   1
         Top             =   30
         Width           =   375
         _version        =   65536
         _extentx        =   661
         _extenty        =   661
         _stockprops     =   78
         bevelwidth      =   1
         roundedcorners  =   0   'False
         outline         =   0   'False
         picture         =   "SQLPDBA.frx":096E
      End
   End
   Begin VB.Menu mfile 
      Caption         =   "&File"
      Begin VB.Menu mconnect 
         Caption         =   "&Connect"
      End
      Begin VB.Menu mdisconnect 
         Caption         =   "&Disconnect!"
         Enabled         =   0   'False
      End
      Begin VB.Menu mexit 
         Caption         =   "E&xit"
      End
   End
   Begin VB.Menu mmanage 
      Caption         =   "&Manage"
      Begin VB.Menu mdevices 
         Caption         =   "&Devices"
      End
      Begin VB.Menu mdatabases 
         Caption         =   "Data&bases"
         Begin VB.Menu mdblist 
            Caption         =   "&List"
         End
         Begin VB.Menu mbackup 
            Caption         =   "&Backup"
         End
      End
      Begin VB.Menu d11 
         Caption         =   "-"
      End
      Begin VB.Menu mobjects 
         Caption         =   "Database &Objects"
      End
   End
   Begin VB.Menu mwindow 
      Caption         =   "&Window"
      Begin VB.Menu marrange 
         Caption         =   "&Cascade"
      End
      Begin VB.Menu mtile 
         Caption         =   "Tile"
         Begin VB.Menu marrange1 
            Caption         =   "&Horizontally"
         End
         Begin VB.Menu marrange2 
            Caption         =   "&Vertically"
         End
      End
      Begin VB.Menu marrange3 
         Caption         =   "&Arrange Icons"
      End
      Begin VB.Menu d12 
         Caption         =   "-"
      End
      Begin VB.Menu mwin 
         Caption         =   ""
         WindowList      =   -1  'True
      End
   End
   Begin VB.Menu mhelp 
      Caption         =   "&Help"
      Begin VB.Menu mabout 
         Caption         =   "&About"
      End
   End
End
Attribute VB_Name = "SQLPDBA"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Dim CurrentType As Integer

Private Sub mabout_Click()
fAbout.Show 1

End Sub

Private Sub marrange_Click()
SQLPDBA.Arrange 0
End Sub

Private Sub marrange1_Click()
SQLPDBA.Arrange 1
End Sub

Private Sub marrange2_Click()
SQLPDBA.Arrange 2

End Sub

Private Sub marrange3_Click()
SQLPDBA.Arrange 3
End Sub

Private Sub mbackup_Click()
Backup.Show 1

End Sub

' Dim OServer As New SQLOLE.SQLServer

Private Sub mconnect_Click()
' connection dialog
fconnect.Show 1

End Sub

Private Sub mdblist_Click()
' database Chart MDI
DBMDI.Show


End Sub

Private Sub mdevices_Click()
DevMDI.Show
End Sub

Private Sub MDIForm_Load()
SQLConnected = False    ' not connected yet
SetDisconnectButtons
End Sub

Private Sub MDIForm_Terminate()
'disconnect from the server if connected
If SQLConnected = True Then
    OServer.DisConnect
    SQLConnected = False
    SetDisconnectButtons
End If
Unload SQLPDBA          ' close app

End Sub

Private Sub mdisconnect_Click()
If SQLConnected = True Then         ' disconnect
    OServer.DisConnect              ' disconnect method
    SQLConnected = False
    StatusBar.Caption = "Not Connected"
    SetDisconnectButtons
    Unload DBMDI
    Unload DevMDI
    Unload ObjMDI
    SQLPDBA.bDB.Enabled = False
    SQLPDBA.bDevice.Enabled = False
    SQLPDBA.bDevice.Enabled = False
    SQLPDBA.bConnect.Enabled = True

End If

End Sub

Private Sub mexit_Click()
' disconnect from the server
If SQLConnected = True Then
    OServer.DisConnect          ' disconnect
    SQLConnected = False
    SetDisconnectButtons
End If
Unload SQLPDBA                  ' close app
End Sub

Private Sub bConnect_Click()
' connection dialog
fconnect.Show 1                 ' show Connect dialog

End Sub

Private Sub bDB_Click()

DBMDI.Show                      ' Display Database Chart MDI


End Sub

Private Sub bDevice_Click()

DevMDI.Show                     ' Display Device Chart MDI

End Sub

Public Sub SetConnectButtons()


    mconnect.Enabled = False    ' disable 'connect' menu
    mdisconnect.Enabled = True  ' enable 'disconnect' menu
'    mLogins.Enabled = True
    mdevices.Enabled = True
    mdatabases.Enabled = True
    mObjects.Enabled = True


End Sub
Public Sub SetDisconnectButtons()


    mconnect.Enabled = True    ' disable 'connect' menu
    mdisconnect.Enabled = False  ' enable 'disconnect' menu
'    mLogins.Enabled = False
    mdevices.Enabled = False
    mdatabases.Enabled = False
    mObjects.Enabled = False


End Sub


Private Sub mObjects_Click()
ObjMDI.Show

End Sub


Private Sub Picture1_Click()

End Sub

Private Sub SSCommand1_Click()
    On Error Resume Next
    
   
   Set MyServer1 = CreateObject("sqlole.SQLServer")  ' Create a SQL Server Object
   MyServer1.Connect "wind2xs", "sa", ""            ' Connect to the SQL Server
       If Err <> 0 Then    ' errors?
          MsgBox Err.Description + " (Press F1 for Help)", 16, Err.Source & " Error", _
          Err.HelpFile, Err.HelpContext
          MousePointer = 0
          Exit Sub
    End If

' you can add additional servers to the collection
  Set MyServer2 = CreateObject("sqlole.SQLServer")  ' Create a SQL Server Object
  MyServer2.Connect "kclaptop", "sa", ""            ' Connect to the SQL Server
       
       If Err <> 0 Then    ' errors?
          MsgBox Err.Description + " (Press F1 for Help)", 16, Err.Source & " Error", _
          Err.HelpFile, Err.HelpContext
          MousePointer = 0
          Exit Sub
    End If
  On Error GoTo 0

   
   IRow = 2

' ==== Loop through the collection of SQLServers ===========
' Set MyServer = CreateObject("sqlole.SQLServer")
 MsgBox Chr$(SQLServers.Count) + " servers "
 
 
 For Each MyServer In SQLOLE.Application.SQLServers
   
   MsgBox "          Working on " + MyServer.Name + "            "
   ICol = 2

' ==== Loop through the collection of Databases on each SQLServer ===========
   Dim MyDatabase As Object
   For Each MyDatabase In MyServer.Databases
       IRow = IRow + 1
    MsgBox MyDatabase.Name
    
'       ActiveSheet.Cells(IRow, 1).Value = MyServer.Name + "." + MyDatabase.Name
'       ActiveSheet.Cells(IRow, 2).Value = 0 ' table count
       ICol = 2
     
' ==== Loop through the collection of Tables on each Database ===========
      For Each MyTable In MyDatabase.Tables
        ICol = ICol + 1
'        MyTable.UpdateStatistics           ' update stats / all indexes
'        ActiveSheet.Cells(IRow, ICol).Value = MyTable.Name
'        ActiveSheet.Cells(IRow, 2).Value = ActiveSheet.Cells(IRow, 2).Value + 1
      Next
   Next
   MyServer.DisConnect  'Disconnect from the server
   
   
   IRow = IRow + 1
 
   
 
 Next

End Sub

