home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / sqldmo / vb / explore / explore.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-06-15  |  46.7 KB  |  1,297 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "SQL-DMO Explorer"
  4.    ClientHeight    =   6705
  5.    ClientLeft      =   3285
  6.    ClientTop       =   2280
  7.    ClientWidth     =   11175
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   6705
  20.    ScaleWidth      =   11175
  21.    Begin VB.TextBox txtProperties 
  22.       Height          =   2535
  23.       Left            =   120
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   3  'Both
  26.       TabIndex        =   13
  27.       Top             =   4080
  28.       Width           =   10935
  29.    End
  30.    Begin VB.CommandButton cmdExit 
  31.       Caption         =   "E&xit"
  32.       Height          =   375
  33.       Left            =   8520
  34.       TabIndex        =   4
  35.       Top             =   120
  36.       Width           =   615
  37.    End
  38.    Begin VB.ComboBox cboFour 
  39.       Enabled         =   0   'False
  40.       Height          =   315
  41.       Left            =   7680
  42.       Sorted          =   -1  'True
  43.       Style           =   2  'Dropdown List
  44.       TabIndex        =   11
  45.       Top             =   600
  46.       Width           =   3375
  47.    End
  48.    Begin VB.ListBox lstFour 
  49.       Enabled         =   0   'False
  50.       Height          =   2985
  51.       Left            =   7680
  52.       TabIndex        =   12
  53.       Top             =   960
  54.       Width           =   3375
  55.    End
  56.    Begin VB.CommandButton cmdConnect 
  57.       Caption         =   "&Connect"
  58.       Default         =   -1  'True
  59.       Enabled         =   0   'False
  60.       Height          =   375
  61.       Left            =   7200
  62.       TabIndex        =   3
  63.       Top             =   120
  64.       Width           =   1215
  65.    End
  66.    Begin VB.TextBox txtPassword 
  67.       Height          =   285
  68.       IMEMode         =   3  'DISABLE
  69.       Left            =   5640
  70.       PasswordChar    =   "*"
  71.       TabIndex        =   2
  72.       Top             =   120
  73.       Width           =   1455
  74.    End
  75.    Begin VB.TextBox txtLogin 
  76.       Height          =   285
  77.       Left            =   3120
  78.       TabIndex        =   1
  79.       Top             =   120
  80.       Width           =   1455
  81.    End
  82.    Begin VB.TextBox txtServer 
  83.       Height          =   285
  84.       Left            =   960
  85.       TabIndex        =   0
  86.       Top             =   120
  87.       Width           =   1455
  88.    End
  89.    Begin VB.ListBox lstThree 
  90.       Enabled         =   0   'False
  91.       Height          =   2985
  92.       Left            =   5160
  93.       TabIndex        =   10
  94.       Top             =   960
  95.       Width           =   2415
  96.    End
  97.    Begin VB.ListBox lstTwo 
  98.       Enabled         =   0   'False
  99.       Height          =   2985
  100.       Left            =   2640
  101.       TabIndex        =   8
  102.       Top             =   960
  103.       Width           =   2415
  104.    End
  105.    Begin VB.ListBox lstOne 
  106.       Enabled         =   0   'False
  107.       Height          =   2985
  108.       Left            =   120
  109.       Sorted          =   -1  'True
  110.       TabIndex        =   6
  111.       Top             =   960
  112.       Width           =   2415
  113.    End
  114.    Begin VB.ComboBox cboThree 
  115.       Enabled         =   0   'False
  116.       Height          =   315
  117.       Left            =   5160
  118.       Sorted          =   -1  'True
  119.       Style           =   2  'Dropdown List
  120.       TabIndex        =   9
  121.       Top             =   600
  122.       Width           =   2415
  123.    End
  124.    Begin VB.ComboBox cboTwo 
  125.       Enabled         =   0   'False
  126.       Height          =   315
  127.       Left            =   2640
  128.       Sorted          =   -1  'True
  129.       Style           =   2  'Dropdown List
  130.       TabIndex        =   7
  131.       Top             =   600
  132.       Width           =   2415
  133.    End
  134.    Begin VB.ComboBox cboOne 
  135.       Enabled         =   0   'False
  136.       Height          =   315
  137.       Left            =   120
  138.       Sorted          =   -1  'True
  139.       Style           =   2  'Dropdown List
  140.       TabIndex        =   5
  141.       Top             =   600
  142.       Width           =   2415
  143.    End
  144.    Begin VB.Label lblPassword 
  145.       Caption         =   "&Password"
  146.       Height          =   255
  147.       Left            =   4680
  148.       TabIndex        =   16
  149.       Top             =   150
  150.       Width           =   855
  151.    End
  152.    Begin VB.Label lblLogin 
  153.       Caption         =   "&Login"
  154.       Height          =   255
  155.       Left            =   2520
  156.       TabIndex        =   15
  157.       Top             =   150
  158.       Width           =   615
  159.    End
  160.    Begin VB.Label lblServer 
  161.       Caption         =   "&Server"
  162.       Height          =   255
  163.       Left            =   120
  164.       TabIndex        =   14
  165.       Top             =   150
  166.       Width           =   735
  167.    End
  168. Attribute VB_Name = "frmMain"
  169. Attribute VB_GlobalNameSpace = False
  170. Attribute VB_Creatable = False
  171. Attribute VB_PredeclaredId = True
  172. Attribute VB_Exposed = False
  173. Option Explicit
  174. Private WithEvents oSQLServer As SQLDMO.SQLServer
  175. Attribute oSQLServer.VB_VarHelpID = -1
  176. ' SQLServer objects.
  177. Private oJobServer As SQLDMO.JobServer
  178. Private oReplication As SQLDMO.Replication
  179. Private oConfiguration As SQLDMO.Configuration
  180. ' Objects selectable at level one.
  181. Private oCurDB As SQLDMO.Database
  182. Private oCurLnkServer As SQLDMO.LinkedServer
  183. Private oCurRemServer As SQLDMO.RemoteServer
  184. Private oDistributor As SQLDMO.Distributor
  185. Private oPublisher As SQLDMO.Publisher
  186. Private oSubscriber As SQLDMO.Subscriber
  187. Private oDistributionPublisher As SQLDMO.DistributionPublisher
  188. Private oDistributionPublication As SQLDMO.DistributionPublication
  189. Private oDistributionPublishers As SQLDMO.DistributionPublishers
  190. Private oDistributionPublications As SQLDMO.DistributionPublications
  191. Private oDistributionSubscriptions As SQLDMO.DistributionSubscriptions
  192. ' Objects selectable at level two.
  193. Private oCurFileGroup As SQLDMO.FileGroup
  194. Private oCurTable As SQLDMO.Table
  195. Private oCurIndex As SQLDMO.Index
  196. Private oCurJob As SQLDMO.Job
  197. Private oCurRepDB As SQLDMO.ReplicationDatabase
  198. ' Objects selectable at level three.
  199. Private oCurMrgPub As SQLDMO.MergePublication
  200. Private oCurRepTable As SQLDMO.ReplicationTable
  201. Private oCurTranPub As SQLDMO.TransPublication
  202. Private bConnected As Boolean
  203. Private StartTime As String
  204. Private Sub cboFour_Click()
  205.     On Error GoTo HandleError
  206.     Dim oQR As SQLDMO.QueryResults
  207.     Dim num As Integer
  208.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  209.     ' to provide feedback.
  210.     frmMain.MousePointer = vbWaitPointer
  211.     'Indexed columns or replication details
  212.     If cboFour.ListIndex = -1 Then
  213.         Exit Sub
  214.     End If
  215.     Select Case cboFour.Text
  216.     Case "Columns"
  217.         Select Case cboThree
  218.         Case "Indexes"
  219.             ' Fill list and text box using the Columns collection of the selected
  220.             ' Index object.
  221.             FillPropsColl oCurIndex.ListIndexedColumns, "Columns"
  222.             FillListFromCollection oCurIndex.ListIndexedColumns, lstFour
  223.             
  224.         Case "ReplicationTables"
  225.             ' Fill list and text box using the Columns collection of the selected
  226.             ' ReplicationTable object.
  227.             FillPropsColl oCurRepTable.Columns, "Columns"
  228.             FillListFromCollection oCurRepTable.Columns, lstFour
  229.         
  230.         End Select
  231.     Case "MergeArticles"
  232.         ' Fill list and text box using the MergeArticles collection of the
  233.         ' selected MergePublication object.
  234.         FillPropsColl oCurMrgPub.MergeArticles, "MergeArticles"
  235.         FillListFromCollection oCurMrgPub.MergeArticles, lstFour
  236.         
  237.     Case "MergeSubscriptions"
  238.         ' Fill list and text box using the MergeSubscriptions collection of the
  239.         ' selected MergePublication object.
  240.         FillPropsColl oCurMrgPub.MergeSubscriptions, "MergeSubscriptions"
  241.         FillListFromCollection oCurMrgPub.MergeSubscriptions, lstFour
  242.     Case "TransArticles"
  243.         ' Fill list and text box using the TransArticles collection of the
  244.         ' selected TransPublication object.
  245.         FillPropsColl oCurTranPub.TransArticles, "TransArticles"
  246.         FillListFromCollection oCurTranPub.TransArticles, lstFour
  247.     Case "TransSubscriptions"
  248.         ' Fill list and text box using the TransSubscriptions collection of the
  249.         ' selected TransPublication object.
  250.         FillPropsColl oCurTranPub.TransSubscriptions, "TransSubscriptions"
  251.         FillListFromCollection oCurTranPub.TransSubscriptions, lstFour
  252. 'Each of the following Case statements gets a result set that contains
  253. 'history information about one of the Agents. The result set contains
  254. '13 columns but we are only interested in 2 of them. To see the other
  255. 'columns and what they contain set a watch on the appropriate value.
  256.     Case "Dist Agent"
  257.         ' Fill list box with Agent History
  258.         ' selected TransPublication object.
  259.         Set oQR = oDistributionPublisher.EnumDistributionAgentSessions(oDistributionPublication.DistributionSubscriptions.Item(1).DistributionAgent, SQLDMOSession_All, 72)
  260.         'Set the array size to the number of rows returned in the result set.
  261.         ReDim strTimes(oQR.Rows)
  262.         
  263.         lstFour.Clear
  264.         For num = 1 To oQR.Rows
  265.             lstFour.AddItem oQR.GetColumnString(num, 4)
  266.             'Add the start times from the result set to the array.
  267.             strTimes(num) = Left(oQR.GetColumnString(num, 3), 22)
  268.         Next
  269.     Case "Snap Agent"
  270.         ' Fill list box with Agent History
  271.         ' selected TransPublication object.
  272.         Set oQR = oDistributionPublisher.EnumSnapshotAgentSessions(oDistributionPublication.SnapshotAgent, SQLDMOSession_All, 72)
  273.         'Set the array size to the number of rows returned in the result set.
  274.         ReDim strTimes(oQR.Rows)
  275.      
  276.         lstFour.Clear
  277.         For num = 1 To oQR.Rows
  278.             lstFour.AddItem oQR.GetColumnString(num, 4)
  279.             'Add the start times from the result set to the array.
  280.             strTimes(num) = Left(oQR.GetColumnString(num, 3), 22)
  281.         Next
  282.      
  283.     Case "Log Agent"
  284.         ' Fill list box with Agent History
  285.         ' selected TransPublication object.
  286.        Set oQR = oDistributionPublisher.EnumLogReaderAgentSessions(oDistributionPublication.LogReaderAgent, SQLDMOSession_All, 72)
  287.         'Set the array size to the number of rows returned in the result set.
  288.         ReDim strTimes(oQR.Rows)
  289.      
  290.         lstFour.Clear
  291.         For num = 1 To oQR.Rows
  292.             lstFour.AddItem oQR.GetColumnString(num, 4)
  293.             'Add the start times from the result set to the array.
  294.             strTimes(num) = Left(oQR.GetColumnString(num, 3), 22)
  295.         Next
  296.     End Select
  297.     If lstFour.ListCount Then
  298.         lstFour.Enabled = True
  299.     End If
  300.     frmMain.MousePointer = vbArrowPointer
  301.     Exit Sub
  302. HandleError:
  303.     PrintError
  304.     Resume Next
  305. End Sub
  306. Private Sub cboOne_Click()
  307.     On Error GoTo HandleError
  308.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  309.     ' to provide feedback.
  310.     frmMain.MousePointer = vbWaitPointer
  311.     'Clear dependent combos and lists
  312.     DisableList lstFour, cboFour
  313.     DisableList lstThree, cboThree
  314.     DisableList lstTwo, cboTwo
  315.     lstOne.Clear
  316.     Set oDistributor = Nothing
  317.     Set oPublisher = Nothing
  318.     Set oSubscriber = Nothing
  319.     Select Case cboOne.Text
  320.     Case "Application"
  321.         ' The Application object exposes collections. Fill the lower level
  322.         ' combobox with the collection names and enable the combobox.
  323.         FillPropsObj oSQLServer.Application
  324.         
  325.         With cboTwo
  326.             .AddItem "ServerGroups"
  327.             .AddItem "SQLServers"
  328.             .Enabled = True
  329.         End With
  330.         
  331.     Case "BackupDevices"
  332.         ' Fill the list allowing the user to explore individual BackupDevice
  333.         ' objects.
  334.         FillPropsColl oSQLServer.BackupDevices, "BackupDevices"
  335.         FillListFromCollection oSQLServer.BackupDevices, lstOne
  336.         
  337.     Case "Configuration"
  338.         ' The Configuration object exposes the ConfigValues. Fill the lower
  339.         ' level combobox with the collection name and enable the combobox.
  340.         FillPropsColl oSQLServer.Configuration.ConfigValues, "ConfigValues"
  341.         
  342.         With cboTwo
  343.             .AddItem "ConfigValues"
  344.             .Enabled = True
  345.         End With
  346.         
  347.     Case "Databases"
  348.         ' Get the properties of the Databases collection. Fill the list with
  349.         ' the name property from Database objects in the collection. Add
  350.         ' Database object collections to the lower level combobox. Selecting
  351.         ' a database from the list control enables the combobox.
  352.         FillPropsColl oSQLServer.Databases, "Databases"
  353.         FillListFromCollection oSQLServer.Databases, lstOne
  354.         
  355.         With cboTwo
  356.             .AddItem "DatabaseRoles"
  357.             .AddItem "Defaults"
  358.             .AddItem "FileGroups"
  359.             .AddItem "FullTextCatalogs"
  360.             .AddItem "Rules"
  361.             .AddItem "StoredProcedures"
  362.             .AddItem "SystemDataTypes"
  363.             .AddItem "Tables"
  364.             .AddItem "TransactionLog"
  365.             .AddItem "UserDefinedDataTypes"
  366.             .AddItem "Users"
  367.             .AddItem "Views"
  368.         End With
  369.     Case "FullTextService"
  370.         ' Display the properties of the FullTextService object.
  371.         FillPropsObj oSQLServer.FullTextService
  372.     Case "JobServer"
  373.         ' The JobServer object exposes collections. Fill the lower level
  374.         ' combobox with the collection names and enable the combobox.
  375.         FillPropsObj oJobServer
  376.         
  377.         With cboTwo
  378.             .AddItem "AlertCategories"
  379.             .AddItem "Alerts"
  380.             .AddItem "AlertSystem"
  381.             .AddItem "JobCategories"
  382.             .AddItem "JobFilter"
  383.             .AddItem "JobHistoryFilter"
  384.             .AddItem "Jobs"
  385.             .AddItem "OperatorCategories"
  386.             .AddItem "Operators"
  387.             .AddItem "TargetServerGroups"
  388.             .AddItem "TargetServers"
  389.             .Enabled = True
  390.         End With
  391.         
  392.     Case "IntegratedSecurity"
  393.         ' Simply enumerate the properties of the object.
  394.         FillPropsObj oSQLServer.IntegratedSecurity
  395.     Case "Languages"
  396.         ' Fill the list allowing the user to explore individual Language
  397.         ' objects.
  398.         FillPropsColl oSQLServer.Languages, "Languages"
  399.         FillListFromCollection oSQLServer.Languages, lstOne
  400.         
  401.     Case "LinkedServers"
  402.         ' Get the properties of the LinkedServers collection. Fill the list
  403.         ' with enumerated LinkedServer objects in the collection. Add
  404.         ' LinkedServer object collection to the lower level combobox. Selecting
  405.         ' a linked server from the list control enables the combobox.
  406.         FillPropsColl oSQLServer.LinkedServers, "LinkedServers"
  407.         FillListFromCollection oSQLServer.LinkedServers, lstOne
  408.         
  409.         cboTwo.AddItem "LinkedServerLogins"
  410.     Case "Logins"
  411.         ' Fill the list allowing the user to explore individual Login
  412.         ' objects.
  413.         FillPropsColl oSQLServer.Logins, "Logins"
  414.         FillListFromCollection oSQLServer.Logins, lstOne
  415.     Case "Registry"
  416.         ' Simply enumerate the properties of the object.
  417.         FillPropsObj oSQLServer.Registry
  418.     Case "RemoteServers"
  419.         ' Get the properties of the RemoteServers collection. Fill the list
  420.         ' with enumerated RemoteServer objects in the collection. Add
  421.         ' RemoteServer object collection to the lower level combobox. Selecting
  422.         ' a remote server from the list control enables the combobox.
  423.         FillPropsColl oSQLServer.RemoteServers, "RemoteServers"
  424.         FillListFromCollection oSQLServer.RemoteServers, lstOne
  425.         
  426.         cboTwo.AddItem "RemoteLogins"
  427.     Case "Replication"
  428.         ' The Replication object exposes collections. Fill the lower level
  429.         ' combobox with the collection names and enable the combobox.
  430.         FillPropsObj oReplication
  431.         
  432.         Set oDistributor = oReplication.Distributor
  433.         Set oPublisher = oReplication.Publisher
  434.         Set oSubscriber = oReplication.Subscriber
  435.         
  436.         With cboTwo
  437.             .AddItem "Distributor"
  438.             .AddItem "Publisher"
  439.             .AddItem "ReplicationDatabases"
  440.             .AddItem "Subscriber"
  441.             .Enabled = True
  442.         End With
  443.         
  444.     Case "ServerRoles"
  445.         ' Fill the list allowing the user to explore individual ServerRole
  446.         ' objects.
  447.         FillPropsColl oSQLServer.ServerRoles, "ServerRoles"
  448.         FillListFromCollection oSQLServer.ServerRoles, lstOne
  449.     End Select
  450.     If lstOne.ListCount Then
  451.         lstOne.Enabled = True
  452.     Else
  453.         lstOne.Enabled = False
  454.     End If
  455.     frmMain.MousePointer = vbArrowPointer
  456.     Exit Sub
  457. HandleError:
  458.     frmMain.MousePointer = vbArrowPointer
  459.     PrintError
  460.     Resume Next
  461. End Sub
  462. Private Sub cboThree_Click()
  463.     On Error GoTo HandleError
  464.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  465.     ' to provide feedback.
  466.     frmMain.MousePointer = vbWaitPointer
  467.     'Clear dependent combos and lists.
  468.     DisableList lstFour, cboFour
  469.     Select Case cboThree.Text
  470.     ' Table object collections.
  471.     Case "Columns"
  472.         FillPropsColl oCurTable.Columns, "Columns"
  473.         FillListFromCollection oCurTable.Columns, lstThree
  474.         
  475.     Case "Indexes"
  476.         FillPropsColl oCurTable.Indexes, "Indexes"
  477.         FillListFromCollection oCurTable.Indexes, lstThree
  478.         
  479.         cboFour.AddItem "Columns"
  480.         
  481.     Case "Triggers"
  482.         FillPropsColl oCurTable.Triggers, "Triggers"
  483.         FillListFromCollection oCurTable.Triggers, lstThree
  484.         
  485.     Case "Keys"
  486.         FillPropsColl oCurTable.Keys, "Keys"
  487.         FillListFromCollection oCurTable.Keys, lstThree
  488.         
  489.     Case "Checks"
  490.         FillPropsColl oCurTable.Checks, "Checks"
  491.         FillListFromCollection oCurTable.Checks, lstThree
  492.         
  493.     ' FileGroup object collections.
  494.     Case "DBFiles"
  495.         FillPropsColl oCurFileGroup.DBFiles, "DBFiles"
  496.         FillListFromCollection oCurFileGroup.DBFiles, lstThree
  497.             
  498.     ' TransactionLog object collections.
  499.     Case "LogFiles"
  500.         FillPropsColl oCurDB.TransactionLog.LogFiles, "LogFiles"
  501.         FillListFromCollection oCurDB.TransactionLog.LogFiles, lstThree
  502.         
  503.     ' Job object collections.
  504.     Case "JobSchedules"
  505.         FillPropsColl oCurJob.JobSchedules, "JobSchedules"
  506.         FillListFromCollection oCurJob.JobSchedules, lstThree
  507.         
  508.     Case "JobSteps"
  509.         FillPropsColl oCurJob.JobSteps, "JobSteps"
  510.         FillListFromCollection oCurJob.JobSteps, lstThree
  511.     ' Distributor object collections.
  512.     Case "DistributionDatabases"
  513.         FillPropsColl oDistributor.DistributionDatabases, "DistributionDatabases"
  514.         FillListFromCollection oDistributor.DistributionDatabases, lstThree
  515.         
  516.     Case "DistributionPublishers"
  517.         FillPropsColl oDistributor.DistributionPublishers, "DistributionPublishers"
  518.         FillListFromCollection oDistributor.DistributionPublishers, lstThree
  519.         
  520.     ' Publisher object collections.
  521.     Case "RegisteredSubscribers"
  522.         FillPropsColl oPublisher.RegisteredSubscribers, "RegisteredSubscribers"
  523.         FillListFromCollection oPublisher.RegisteredSubscribers, lstThree
  524.     ' ReplicationDatabase object collections.
  525.     Case "MergePublications"
  526.         FillPropsColl oCurRepDB.MergePublications, "MergePublications"
  527.         FillListFromCollection oCurRepDB.MergePublications, lstThree
  528.         
  529.         With cboFour
  530.             .AddItem "MergeArticles"
  531.             .AddItem "MergeSubscriptions"
  532.         End With
  533.         
  534.     Case "MergePullSubscriptions"
  535.         FillPropsColl oCurRepDB.MergePullSubscriptions, "MergePullSubscriptions"
  536.         FillListFromCollection oCurRepDB.MergePullSubscriptions, lstThree
  537.         
  538.     Case "ReplicationStoredProcedures"
  539.         FillPropsColl oCurRepDB.ReplicationStoredProcedures, "ReplicationStoredProcedures"
  540.         FillListFromCollection oCurRepDB.ReplicationStoredProcedures, lstThree
  541.         
  542.     Case "ReplicationTables"
  543.         FillPropsColl oCurRepDB.ReplicationTables, "ReplicationTables"
  544.         FillListFromCollection oCurRepDB.ReplicationTables, lstThree
  545.         
  546.         cboFour.AddItem "Columns"
  547.         
  548.     Case "TransPublications"
  549.         FillPropsColl oCurRepDB.TransPublications, "TransPublications"
  550.         FillListFromCollection oCurRepDB.TransPublications, lstThree
  551.         
  552.         With cboFour
  553.             .AddItem "TransArticles"
  554.             .AddItem "TransSubscriptions"
  555.         End With
  556.         
  557.     Case "TransPullSubscriptions"
  558.         FillPropsColl oCurRepDB.TransPullSubscriptions, "TransPullSubscriptions"
  559.         FillListFromCollection oCurRepDB.TransPullSubscriptions, lstThree
  560.         
  561.     End Select
  562.     If lstThree.ListCount Then
  563.         lstThree.Enabled = True
  564.     Else
  565.         lstThree.Enabled = False
  566.     End If
  567.     frmMain.MousePointer = vbArrowPointer
  568.     Exit Sub
  569. HandleError:
  570.     frmMain.MousePointer = vbArrowPointer
  571.     PrintError
  572.     Resume Next
  573. End Sub
  574. Private Sub cboTwo_Click()
  575.     ' This could take awhile
  576.     frmMain.MousePointer = vbWaitPointer
  577.     'Clear dependent combos and lists
  578.     DisableList lstFour, cboFour
  579.     DisableList lstThree, cboThree
  580.     lstTwo.Clear
  581.     Select Case cboTwo.Text
  582.     ' Application object collections.
  583.     Case "ServerGroups"
  584.         FillListFromCollection oSQLServer.Application.ServerGroups, lstTwo
  585.     Case "SQLServers"
  586.         FillListFromCollection oSQLServer.Application.SQLServers, lstTwo
  587.     ' Configuration object collections.
  588.     Case "ConfigValues"
  589.         FillListFromCollection oSQLServer.Configuration.ConfigValues, lstTwo
  590.     ' Database object collections.
  591.     Case "DatabaseRoles"
  592.         FillPropsColl oCurDB.DatabaseRoles, "DatabaseRoles"
  593.         FillListFromCollection oCurDB.DatabaseRoles, lstTwo
  594.         
  595.     Case "Defaults"
  596.         FillPropsColl oCurDB.Defaults, "Defaults"
  597.         FillListFromCollection oCurDB.Defaults, lstTwo
  598.             
  599.     Case "FileGroups"
  600.         FillPropsColl oCurDB.FileGroups, "FileGroups"
  601.         FillListFromCollection oCurDB.FileGroups, lstTwo
  602.         
  603.         cboThree.AddItem "DBFiles"
  604.         
  605.     Case "FullTextCatalogs"
  606.         FillPropsColl oCurDB.FullTextCatalogs, "FullTextCatalogs"
  607.         FillListFromCollection oCurDB.FullTextCatalogs, lstTwo
  608.         
  609.     Case "Rules"
  610.         FillPropsColl oCurDB.Rules, "Rules"
  611.         FillListFromCollection oCurDB.Rules, lstTwo
  612.     Case "StoredProcedures"
  613.         FillPropsColl oCurDB.StoredProcedures, "StoredProcedures"
  614.         FillListFromCollection oCurDB.StoredProcedures, lstTwo
  615.     Case "SystemDataTypes"
  616.         FillPropsColl oCurDB.SystemDatatypes, "SystemDatatypes"
  617.         FillListFromCollection oCurDB.SystemDatatypes, lstTwo
  618.         
  619.     Case "Tables"
  620.         FillPropsColl oCurDB.Tables, "Tables"
  621.         FillListFromCollection oCurDB.Tables, lstTwo
  622.         
  623.         With cboThree
  624.             .AddItem "Checks"
  625.             .AddItem "Columns"
  626.             .AddItem "Indexes"
  627.             .AddItem "Keys"
  628.             .AddItem "Triggers"
  629.         End With
  630.         
  631.     Case "TransactionLog"
  632.         FillPropsObj oCurDB.TransactionLog
  633.         
  634.         With cboThree
  635.             .AddItem "LogFiles"
  636.             .Enabled = True
  637.         End With
  638.         
  639.     Case "UserDefinedDataTypes"
  640.         FillPropsColl oCurDB.UserDefinedDatatypes, "UserDefinedDatatypes"
  641.         FillListFromCollection oCurDB.UserDefinedDatatypes, lstTwo
  642.         
  643.     Case "Users"
  644.         FillPropsColl oCurDB.Users, "Users"
  645.         FillListFromCollection oCurDB.Users, lstTwo
  646.         
  647.     Case "Views"
  648.         FillPropsColl oCurDB.Views, "Views"
  649.         FillListFromCollection oCurDB.Views, lstTwo
  650.         
  651.     ' JobServer object collections.
  652.     Case "AlertCategories"
  653.         FillPropsColl oJobServer.AlertCategories, "AlertCategories"
  654.         FillListFromCollection oJobServer.AlertCategories, lstTwo
  655.     Case "Alerts"
  656.         FillPropsColl oJobServer.Alerts, "Alerts"
  657.         FillListFromCollection oJobServer.Alerts, lstTwo
  658.         
  659.     Case "AlertSystem"
  660.         FillPropsObj oJobServer.AlertSystem
  661.     Case "JobCategories"
  662.         FillPropsColl oJobServer.JobCategories, "JobCategories"
  663.         FillListFromCollection oJobServer.JobCategories, lstTwo
  664.     Case "JobFilter"
  665.         FillPropsObj oJobServer.JobFilter
  666.     Case "JobHistoryFilter"
  667.         FillPropsObj oJobServer.JobHistoryFilter
  668.         
  669.     Case "Jobs"
  670.         FillPropsColl oJobServer.Jobs, "Jobs"
  671.         FillListFromCollection oJobServer.Jobs, lstTwo
  672.         
  673.         With cboThree
  674.             .AddItem "JobSchedules"
  675.             .AddItem "JobSteps"
  676.         End With
  677.         
  678.     Case "OperatorCategories"
  679.         FillPropsColl oJobServer.OperatorCategories, "OperatorCategories"
  680.         FillListFromCollection oJobServer.OperatorCategories, lstTwo
  681.         
  682.     Case "Operators"
  683.         FillPropsColl oJobServer.Operators, "Operators"
  684.         FillListFromCollection oJobServer.Operators, lstTwo
  685.     Case "TargetServerGroups"
  686.         FillPropsColl oJobServer.TargetServerGroups, "TargetServerGroups"
  687.         FillListFromCollection oJobServer.TargetServerGroups, lstTwo
  688.     Case "TargetServers"
  689.         FillPropsColl oJobServer.TargetServers, "TargetServers"
  690.         FillListFromCollection oJobServer.TargetServers, lstTwo
  691.     ' LinkedServer object collections.
  692.     Case "LinkedServerLogins"
  693.         FillPropsColl oCurLnkServer.LinkedServerLogins, "LinkedServerLogins"
  694.         FillListFromCollection oCurLnkServer.LinkedServerLogins, lstTwo
  695.         
  696.     ' RemoteServer object collections.
  697.     Case "RemoteLogins"
  698.         FillPropsColl oCurRemServer.RemoteLogins, "RemoteLogins"
  699.         FillListFromCollection oCurRemServer.RemoteLogins, lstTwo
  700.     ' Replication object collections.
  701.     Case "Distributor"
  702.         FillPropsObj oReplication.Distributor
  703.         
  704.         With cboThree
  705.             .AddItem "DistributionDatabases"
  706.             .AddItem "DistributionPublishers"
  707.             .Enabled = True
  708.         End With
  709.                 
  710.     Case "Publisher"
  711.         FillPropsObj oReplication.Publisher
  712.         
  713.         With cboThree
  714.             .AddItem "RegisteredSubscribers"
  715.             .Enabled = True
  716.         End With
  717.                 
  718.     Case "ReplicationDatabases"
  719.         FillPropsColl oReplication.ReplicationDatabases, "ReplicationDatabases"
  720.         FillListFromCollection oReplication.ReplicationDatabases, lstTwo
  721.         
  722.         With cboThree
  723.             .AddItem "MergePublications"
  724.             .AddItem "MergePullSubscriptions"
  725.             .AddItem "ReplicationStoredProcedures"
  726.             .AddItem "ReplicationTables"
  727.             .AddItem "TransPublications"
  728.             .AddItem "TransPullSubscriptions"
  729.         End With
  730.         
  731.     Case "Subscriber"
  732.         FillPropsObj oReplication.Distributor
  733.         
  734.         With cboThree
  735.             .AddItem "RegisteredPublishers"
  736.             .Enabled = True
  737.         End With
  738.     End Select
  739.     If lstTwo.ListCount Then
  740.         lstTwo.Enabled = True
  741.     Else
  742.         lstTwo.Enabled = False
  743.     End If
  744.     frmMain.MousePointer = vbArrowPointer
  745. End Sub
  746. Private Sub cmdConnect_Click()
  747.     On Error GoTo HandleError
  748.         
  749.     'If we're connected, then disconnect and clear lists
  750.     If bConnected = True Then
  751.         With lstOne
  752.             .Clear
  753.             .Enabled = False
  754.         End With
  755.         
  756.         With cboOne
  757.             .ListIndex = -1
  758.             .Enabled = False
  759.         End With
  760.         
  761.         DisableList lstTwo, cboTwo
  762.         DisableList lstThree, cboThree
  763.         DisableList lstFour, cboFour
  764.         
  765.         txtProperties.Text = "" & NL
  766.         
  767.         lblServer.Enabled = True
  768.         txtServer.Enabled = True
  769.         lblLogin.Enabled = True
  770.         txtLogin.Enabled = True
  771.         lblPassword.Enabled = True
  772.         txtPassword.Enabled = True
  773.         
  774.         cmdConnect.Caption = "&Connect"
  775.         cmdConnect.Default = True
  776.         
  777.         bConnected = False
  778.         
  779.         oSQLServer.DisConnect
  780.         Set oJobServer = Nothing
  781.         Set oReplication = Nothing
  782.         Set oConfiguration = Nothing
  783.         Exit Sub
  784.     End If
  785.     'Set mouse pointer to "Wait" cursor
  786.     frmMain.MousePointer = vbWaitPointer
  787.     'Attempt a connection, then fill the properties stuff
  788.     oSQLServer.ApplicationName = "SQL-DMO Explorer"
  789.     oSQLServer.Connect txtServer.Text, txtLogin.Text, txtPassword.Text
  790.     oSQLServer.Application.GroupRegistrationServer = ""
  791.     lblServer.Enabled = False
  792.     txtServer.Enabled = False
  793.     lblLogin.Enabled = False
  794.     txtLogin.Enabled = False
  795.     lblPassword.Enabled = False
  796.     txtPassword.Enabled = False
  797.     cmdConnect.Caption = "&Disconnect"
  798.     cmdConnect.Default = False
  799.     bConnected = True
  800.         
  801.     cboOne.Enabled = True
  802.     lstOne.Enabled = True
  803.         
  804.     oSQLServer.Configuration.ShowAdvancedOptions = True
  805.     Set oJobServer = oSQLServer.JobServer
  806.     Set oReplication = oSQLServer.Replication
  807.     Set oConfiguration = oSQLServer.Configuration
  808.     FillPropsObj oSQLServer
  809.     frmMain.MousePointer = vbArrowPointer
  810.     Exit Sub
  811.         
  812. HandleError:
  813.     frmMain.MousePointer = vbArrowPointer
  814.     PrintError
  815.     Exit Sub
  816. End Sub
  817. Private Sub cmdExit_Click()
  818.     Unload frmMain
  819. End Sub
  820. Private Sub Form_Load()
  821.     On Error Resume Next
  822.     NL = Chr$(13) & Chr$(10)
  823.     bConnected = False
  824.     Set oSQLServer = New SQLDMO.SQLServer
  825.     oSQLServer.LoginTimeout = 10
  826.     oSQLServer.ODBCPrefix = False
  827.     With cboOne
  828.         .Clear
  829.         .AddItem "Application"
  830.         .AddItem "BackupDevices"
  831.         .AddItem "Configuration"
  832.         .AddItem "Databases"
  833.         .AddItem "IntegratedSecurity"
  834.         .AddItem "FullTextService"
  835.         .AddItem "JobServer"
  836.         .AddItem "Languages"
  837.         .AddItem "LinkedServers"
  838.         .AddItem "Logins"
  839.         .AddItem "Registry"
  840.         .AddItem "RemoteServers"
  841.         .AddItem "Replication"
  842.         .AddItem "ServerRoles"
  843.     End With
  844. End Sub
  845. Private Sub Form_Unload(Cancel As Integer)
  846.     On Error Resume Next
  847.     If bConnected = True Then
  848.         oSQLServer.DisConnect
  849.     End If
  850.     oSQLServer.Close
  851. End Sub
  852. Private Sub lstFour_Click()
  853.     On Error GoTo HandleError
  854.     Dim oQR As SQLDMO.QueryResults
  855.     Dim strExec As String
  856.     Dim strMessage As String
  857.     Dim nProc, num As Integer
  858.     Dim strSProc As String
  859.     Dim strSProcs As String
  860.     Dim strParams As String
  861.     Dim oDBObj As SQLDMO.DBObject
  862.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  863.     ' to provide feedback.
  864.     frmMain.MousePointer = vbWaitPointer
  865.     Select Case cboFour.Text
  866.         Case "Columns"
  867.             Select Case cboThree.Text
  868.             Case "Indexes"
  869.                 FillPropsObj oCurTable.Columns(lstFour.Text)
  870.                 
  871.             Case "ReplicationTables"
  872.                 FillPropsObj oCurRepTable.Columns(lstFour.Text)
  873.             
  874.             End Select
  875.             
  876.         Case "MergeArticles"
  877.             FillPropsObj oCurMrgPub.MergeArticles(lstFour.Text)
  878.             
  879.         Case "MergeSubscriptions"
  880.             FillPropsObj oCurMrgPub.MergeSubscriptions(lstFour.Text)
  881.             
  882.         Case "TransArticles"
  883.             FillPropsObj oCurTranPub.TransArticles(lstFour.ListIndex + 1)
  884.         
  885.         Case "TransSubscriptions"
  886.             FillPropsObj oCurTranPub.TransSubscriptions(lstFour.ListIndex + 1)
  887.             
  888.         Case "Dist Agent"
  889.             Set oQR = oDistributionPublisher.EnumDistributionAgentSessionDetails(oDistributionPublication.DistributionSubscriptions.Item(1).DistributionAgent, strTimes(lstFour.ListIndex + 1))
  890.             With frmMain.txtProperties
  891.                 .Text = ""
  892.                 For num = 1 To oQR.Rows
  893.                     .Text = .Text & oQR.GetColumnString(num, 3) & ": "
  894.                     .Text = .Text & NL
  895.                Next
  896.             End With
  897.           
  898.         Case "Snap Agent"
  899.             Set oQR = oDistributionPublisher.EnumSnapshotAgentSessionDetails(oDistributionPublication.SnapshotAgent, strTimes(lstFour.ListIndex + 1))
  900.             With frmMain.txtProperties
  901.                 .Text = ""
  902.                 For num = 1 To oQR.Rows
  903.                     .Text = .Text & oQR.GetColumnString(num, 3) & ": "
  904.                     .Text = .Text & NL
  905.                Next
  906.             End With
  907.           
  908.         Case "Log Agent"
  909.             Set oQR = oDistributionPublisher.EnumLogReaderAgentSessionDetails(oDistributionPublication.LogReaderAgent, strTimes(lstFour.ListIndex + 1))
  910.             With frmMain.txtProperties
  911.                 .Text = ""
  912.                 For num = 1 To oQR.Rows
  913.                     .Text = .Text & oQR.GetColumnString(num, 3) & ": "
  914.                     .Text = .Text & NL
  915.                Next
  916.             End With
  917.             
  918.             
  919.     End Select
  920.     frmMain.MousePointer = vbArrowPointer
  921.     Exit Sub
  922. HandleError:
  923.     frmMain.MousePointer = vbArrowPointer
  924.     PrintError
  925. End Sub
  926. Private Sub lstOne_Click()
  927.     On Error GoTo HandleError
  928.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  929.     ' to provide feedback.
  930.     frmMain.MousePointer = vbWaitPointer
  931.     Set oCurDB = Nothing
  932.     Set oCurLnkServer = Nothing
  933.     Set oCurRemServer = Nothing
  934.     Select Case cboOne.Text
  935.     Case "BackupDevices"
  936.         ' Get the properties of the selected BackupDevice object.
  937.         FillPropsObj oSQLServer.BackupDevices(lstOne.Text)
  938.         
  939.     Case "Databases"
  940.         ' Get the properties of the selected Database object. Record
  941.         ' the selection for exploration of Database collections and objects.
  942.         Set oCurDB = oSQLServer.Databases(lstOne.Text)
  943.         FillPropsObj oCurDB
  944.         
  945.     Case "Languages"
  946.         ' Get the properties of the selected Language object.
  947.         FillPropsObj oSQLServer.Languages(lstOne.Text)
  948.         
  949.     Case "LinkedServers"
  950.         ' Get the properties of the selected LinkedServer object. Record
  951.         ' the selection for exploration of database objects.
  952.         Set oCurLnkServer = oSQLServer.LinkedServers(lstOne.Text)
  953.         FillPropsObj oCurLnkServer
  954.         
  955.     Case "Logins"
  956.         ' Get the properties of the selected Login object.
  957.         FillPropsObj oSQLServer.Logins(lstOne.Text)
  958.         
  959.     Case "RemoteServers"
  960.         ' Get the properties of the selected RemoteServer object. Record
  961.         ' the selection for exploration of RemoteServer collections.
  962.         Set oCurRemServer = oSQLServer.RemoteServers(lstOne.Text)
  963.         FillPropsObj oCurRemServer
  964.         
  965.     Case "ServerRoles"
  966.         ' Get the properties of the selected ServerRole object.
  967.         FillPropsObj oSQLServer.ServerRoles(lstOne.Text)
  968.         
  969.     End Select
  970.     If cboTwo.ListCount Then
  971.         cboTwo.Enabled = True
  972.     End If
  973.     cboTwo_Click
  974.     frmMain.MousePointer = vbArrowPointer
  975.     Exit Sub
  976. HandleError:
  977.     frmMain.MousePointer = vbArrowPointer
  978.     PrintError
  979. End Sub
  980. Private Sub lstThree_Click()
  981.     On Error GoTo HandleError
  982.     Dim oQR As SQLDMO.QueryResults
  983.     Dim oDBObj As SQLDMO.DBObject
  984.     Dim ret As Integer
  985.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  986.     ' to provide feedback.
  987.     frmMain.MousePointer = vbWaitPointer
  988.     Set oCurMrgPub = Nothing
  989.     Set oCurTranPub = Nothing
  990.     Set oCurRepTable = Nothing
  991.     Select Case cboThree.Text
  992.     ' Table object collections.
  993.     Case "Columns"
  994.         FillPropsObj oCurTable.Columns(lstThree.Text)
  995.     Case "Indexes"
  996.         Set oCurIndex = oCurTable.Indexes(lstThree.Text)
  997.         FillPropsObj oCurIndex
  998.         
  999.         cboFour_Click
  1000.         
  1001.     Case "Triggers"
  1002.         FillPropsObj oCurTable.Triggers(lstThree.Text)
  1003.         
  1004.     Case "Keys"
  1005.         FillPropsObj oCurTable.Keys(lstThree.Text)
  1006.         
  1007.     Case "Checks"
  1008.         FillPropsObj oCurTable.Checks(lstThree.Text)
  1009.     ' DBFile object.
  1010.     Case "DBFiles"
  1011.         FillPropsObj oCurFileGroup.DBFiles(lstThree.ListIndex + 1)
  1012.     ' Job object collections.
  1013.     Case "JobSchedules"
  1014.         FillPropsObj oCurJob.JobSchedules(lstThree.ListIndex + 1)
  1015.     Case "JobSteps"
  1016.         FillPropsObj oCurJob.JobSteps(lstThree.List(lstThree.ListIndex))
  1017.             
  1018.     Case "LogFiles"
  1019.         FillPropsObj oCurDB.TransactionLog.LogFiles(lstThree.ListIndex + 1)
  1020.     Case "DistributionDatabases"
  1021.         FillPropsObj oReplication.Distributor.DistributionDatabases(lstThree.Text)
  1022.     Case "DistributionPublishers"
  1023.         'Get information for the selected Publisher
  1024.         FillPropsObj oReplication.Distributor.DistributionPublishers(lstThree.Text)
  1025.         Set oDistributionPublisher = oReplication.Distributor.DistributionPublishers(lstThree.Text)
  1026.         
  1027.         Set oDistributionPublication = oDistributionPublisher.DistributionPublications.Item(1)
  1028.      
  1029.         lstFour.Clear
  1030.         cboFour.Clear
  1031.         With cboFour
  1032.                 .AddItem "Dist Agent"
  1033.                 .AddItem "Snap Agent"
  1034.                 .AddItem "Log Agent"
  1035.         End With
  1036.         cboFour_Click
  1037.      
  1038.     Case "MergePublications"
  1039.         Set oCurMrgPub = oCurRepDB.MergePublications(lstThree.ListIndex + 1)
  1040.         FillPropsObj oCurMrgPub
  1041.                 
  1042.     Case "MergePullSubscriptions"
  1043.         FillPropsObj oCurRepDB.MergePullSubscriptions(lstThree.ListIndex + 1)
  1044.     Case "ReplicationStoredProcedures"
  1045.         FillPropsObj oCurRepDB.ReplicationStoredProcedures(lstThree.ListIndex + 1)
  1046.     Case "ReplicationTables"
  1047.         Set oCurRepTable = oCurRepDB.ReplicationTables(lstThree.Text)
  1048.         FillPropsObj oCurRepTable
  1049.     Case "TransPublications"
  1050.         Set oCurTranPub = oCurRepDB.TransPublications(lstThree.ListIndex + 1)
  1051.         FillPropsObj oCurTranPub
  1052.                 
  1053.     Case "TransPullSubscriptions"
  1054.         FillPropsObj oCurRepDB.TransPullSubscriptions(lstThree.ListIndex + 1)
  1055.     End Select
  1056.     If cboFour.ListCount Then
  1057.         cboFour.Enabled = True
  1058.     End If
  1059.     cboFour_Click
  1060.     frmMain.MousePointer = vbArrowPointer
  1061.     Exit Sub
  1062. HandleError:
  1063.     frmMain.MousePointer = vbArrowPointer
  1064.     PrintError
  1065. End Sub
  1066. Private Sub lstTwo_Click()
  1067.     On Error GoTo HandleError
  1068.     Set oCurFileGroup = Nothing
  1069.     Set oCurTable = Nothing
  1070.     Set oCurJob = Nothing
  1071.     Set oCurRepDB = Nothing
  1072.     ' Any SQL Server access involves time. Set the MousePointer to "wait"
  1073.     ' to provide feedback.
  1074.     frmMain.MousePointer = vbWaitPointer
  1075.     Select Case cboTwo.Text
  1076.     ' Configuration object ConfigValues collection.
  1077.     Case "ConfigValues"
  1078.         ' Display the properties of the selected ConfigValue object.
  1079.         FillPropsObj oConfiguration.ConfigValues(lstTwo.Text)
  1080.     ' Database object collections.
  1081.     Case "Defaults"
  1082.         ' Display the properties of the selected Default object.
  1083.         FillPropsObj oCurDB.Defaults(lstTwo.Text)
  1084.         
  1085.     Case "DatabaseRoles"
  1086.         ' Display the properties of the selected DatabaseRole object.
  1087.         FillPropsObj oCurDB.DatabaseRoles(lstTwo.Text)
  1088.         
  1089.     Case "FileGroups"
  1090.         ' Display the properties of the selected FileGroup object.
  1091.         Set oCurFileGroup = oCurDB.FileGroups(lstTwo.Text)
  1092.         FillPropsObj oCurDB.FileGroups(lstTwo.Text)
  1093.         
  1094.     Case "FullTextCatalogs"
  1095.         ' Display the properties of the selected FullTextCatalog object.
  1096.         FillPropsObj oCurDB.FullTextCatalogs(lstTwo.Text)
  1097.         
  1098.     Case "Rules"
  1099.         ' Display the properties of the selected Rule object.
  1100.         FillPropsObj oCurDB.Rules(lstTwo.Text)
  1101.         
  1102.     Case "StoredProcedures"
  1103.         ' Display the properties of the selected StoredProcedure object.
  1104.         FillPropsObj oCurDB.StoredProcedures(lstTwo.Text)
  1105.         
  1106.     Case "SystemDataTypes"
  1107.         ' Display the properties of the selected SystemDataType object.
  1108.         FillPropsObj oCurDB.SystemDatatypes(lstTwo.Text)
  1109.         
  1110.     Case "Tables"
  1111.         ' Display the properties of the selected Table object.
  1112.         Set oCurTable = oCurDB.Tables(lstTwo.Text)
  1113.         FillPropsObj oCurTable
  1114.         
  1115.     Case "UserDefinedDataTypes"
  1116.         ' Display the properties of the selected UserDefinedDataType object.
  1117.         FillPropsObj oCurDB.UserDefinedDatatypes(lstTwo.Text)
  1118.         
  1119.     Case "Users"
  1120.         ' Display the properties of the selected User object.
  1121.         FillPropsObj oCurDB.Users(lstTwo.Text)
  1122.         
  1123.     Case "Views"
  1124.         ' Display the properties of the selected View object.
  1125.         FillPropsObj oCurDB.Views(lstTwo.Text)
  1126.         
  1127.     ' JobServer object collections.
  1128.     Case "AlertCategories"
  1129.         ' Display the properties of the selected AlertCategory object.
  1130.         FillPropsObj oJobServer.AlertCategories(lstTwo.Text)
  1131.         
  1132.     Case "Alerts"
  1133.         ' Display the properties of the selected Alert object.
  1134.         FillPropsObj oJobServer.Alerts(lstTwo.Text)
  1135.         
  1136.     Case "JobCategories"
  1137.         ' Display the properties of the selected JobCategory object.
  1138.         FillPropsObj oJobServer.JobCategories(lstTwo.Text)
  1139.         
  1140.     Case "Jobs"
  1141.         ' Display the properties of the selected Job object.
  1142.         Set oCurJob = oJobServer.Jobs(lstTwo.Text)
  1143.         FillPropsObj oCurJob
  1144.         
  1145.     Case "OperatorCategories"
  1146.         ' Display the properties of the selected OperatorCategory object.
  1147.         FillPropsObj oJobServer.OperatorCategories(lstTwo.Text)
  1148.         
  1149.     Case "Operators"
  1150.         ' Display the properties of the selected Operator object.
  1151.         FillPropsObj oJobServer.Operators(lstTwo.Text)
  1152.         
  1153.     Case "TargetServerGroups"
  1154.         ' Display the properties of the selected TargetServerGroup object.
  1155.         FillPropsObj oJobServer.TargetServerGroups(lstTwo.Text)
  1156.         
  1157.     Case "TargetServers"
  1158.         ' Display the properties of the selected TargetServer object.
  1159.         FillPropsObj oJobServer.TargetServers(lstTwo.Text)
  1160.     ' LinkedServer object, LinkedServerLogins collection.
  1161.     Case "LinkedServerLogins"
  1162.         ' Display the properties of the selected LinkedServerLogin object.
  1163.         FillPropsObj oCurLnkServer.LinkedServerLogins(lstTwo.Text)
  1164.     ' RemoteServer object, RemoteLogins collection.
  1165.     Case "RemoteLogins"
  1166.         ' Display the properties of the selected RemoteLogin object.
  1167.         FillPropsObj oCurRemServer.RemoteLogins(lstTwo.Text)
  1168.     ' Replication object, ReplicationDatabases collection.
  1169.     Case "ReplicationDatabases"
  1170.         ' Display the properties of the selected ReplicationDatabase object.
  1171.         Set oCurRepDB = oReplication.ReplicationDatabases(lstTwo.Text)
  1172.         FillPropsObj oCurRepDB
  1173.         
  1174.     End Select
  1175.     If cboThree.ListCount Then
  1176.         cboThree.Enabled = True
  1177.     End If
  1178.     cboThree_Click
  1179.     frmMain.MousePointer = vbArrowPointer
  1180.     Exit Sub
  1181. HandleError:
  1182.     frmMain.MousePointer = vbArrowPointer
  1183.     PrintError
  1184. End Sub
  1185. Private Sub oSQLServer_CommandSent(ByVal SQLCommand As String)
  1186. '    MsgBox SQLCommand$, vbInformation, "SQL Server Command Sent"
  1187.     Exit Sub
  1188. End Sub
  1189. Private Function oSQLServer_ConnectionBroken(ByVal Message As String) As Boolean
  1190.     cmdConnect.Caption = "&Connect"
  1191.     bConnected = False
  1192. End Function
  1193. Private Function oSQLServer_QueryTimeout(ByVal Message As String) As Boolean
  1194.     MsgBox Message$
  1195. End Function
  1196. Private Sub oSQLServer_RemoteLoginFailed(ByVal Severity As Long, ByVal MessageNumber As Long, ByVal MessageState As Long, ByVal Message As String)
  1197.     If MessageNumber <> 0 Then
  1198.         Dim strMsg As String
  1199.         strMsg$ = "Number: " & MessageNumber & NL & "Text: " & Message
  1200.         MsgBox strMsg$, vbExclamation, "SQL Server Remote Login Failure"
  1201.     End If
  1202. End Sub
  1203. Private Sub oSQLServer_ServerMessage(ByVal Severity As Long, ByVal MessageNumber As Long, ByVal MessageState As Long, ByVal Message As String)
  1204. '    If MessageNumber <> 0 Then
  1205. '        Dim strMsg As String
  1206. '        strMsg$ = "Number: " & MessageNumber & NL & "Text: " & Message
  1207. '        MsgBox strMsg$, vbInformation, "SQL Server Information"
  1208. '    End If
  1209. End Sub
  1210. Sub DisableList(lst As ListBox, cbo As ComboBox)
  1211.     With cbo
  1212.         .Clear
  1213.         .Enabled = False
  1214.     End With
  1215.     With lst
  1216.         .Clear
  1217.         .Enabled = False
  1218.     End With
  1219. End Sub
  1220. Sub FillListFromCollection(oCollection As Object, lst As ListBox)
  1221.     On Error GoTo HandleError
  1222.     lst.Clear
  1223.     Dim oObject As Object
  1224.     For Each oObject In oCollection
  1225.         Select Case oObject.TypeOf
  1226.         Case SQLDMOObj_TargetServer
  1227.             lst.AddItem oObject.ServerName
  1228.             
  1229.         Case SQLDMOObj_RemoteLogin
  1230.             lst.AddItem oObject.LocalName
  1231.             
  1232.         Case SQLDMOObj_LinkedServerLogin
  1233.             lst.AddItem oObject.LocalLogin
  1234.             
  1235.         Case Else
  1236.             lst.AddItem oObject.Name
  1237.         End Select
  1238. NoValue:
  1239.     Next oObject
  1240.     Exit Sub
  1241. HandleError:
  1242.     PrintError
  1243.     Resume NoValue
  1244. End Sub
  1245. Sub FillPropsColl(oCollection As Object, strName As String)
  1246.     On Error GoTo HandleError
  1247.     With frmMain.txtProperties
  1248.         .Text = "Properties for: " & strName
  1249.         .Text = .Text & NL
  1250.         
  1251.         .Text = .Text & "Count: " & oCollection.Count
  1252.         .Text = .Text & NL
  1253.     End With
  1254.     Exit Sub
  1255. HandleError:
  1256.     PrintError
  1257.     Exit Sub
  1258. End Sub
  1259. Sub FillPropsObj(oObject As Object)
  1260.     On Error GoTo HandleError
  1261.     Dim oProperty As Object
  1262.     With frmMain.txtProperties
  1263.         .Text = ""
  1264.         For Each oProperty In oObject.Properties
  1265.             .Text = .Text & oProperty.Name & ": "
  1266.             .Text = .Text & oProperty.Value
  1267. NoValue:
  1268.             .Text = .Text & NL
  1269.         Next
  1270.     End With
  1271.     Exit Sub
  1272. HandleError:
  1273.     If Err.Number = 438 Then
  1274.         With frmMain.txtProperties
  1275.             .Text = .Text & "Value is write-only"
  1276.         End With
  1277.         Resume Next
  1278.     Else
  1279.         PrintError
  1280.         Resume NoValue
  1281.     End If
  1282. End Sub
  1283. Sub PrintError()
  1284.     Dim errString As String
  1285.     If Err.Number <> 0 Then
  1286.         errString$ = Err.Source & " Error " & Err.Number & ": " & Err.Description
  1287.         MsgBox errString$
  1288.     End If
  1289. End Sub
  1290. Private Sub txtServer_Change()
  1291.     If Len(txtServer.Text) Then
  1292.         cmdConnect.Enabled = True
  1293.     Else
  1294.         cmdConnect.Enabled = False
  1295.     End If
  1296. End Sub
  1297.