home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Internet Business Development Kit / PRODUCT_CD.iso / sqlsvr / i386 / sqlpdba.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-12  |  9.6 KB  |  310 lines

  1. VERSION 4.00
  2. Begin VB.MDIForm SQLPDBA 
  3.    BackColor       =   &H8000000C&
  4.    Caption         =   "Microsoft SQL Server - sample "
  5.    ClientHeight    =   5790
  6.    ClientLeft      =   1185
  7.    ClientTop       =   1815
  8.    ClientWidth     =   7905
  9.    Height          =   6480
  10.    Icon            =   "SQLPDBA.frx":0000
  11.    Left            =   1125
  12.    LinkTopic       =   "MDIForm1"
  13.    Top             =   1185
  14.    Width           =   8025
  15.    Begin Threed.SSPanel StatusBar 
  16.       Align           =   2  'Align Bottom
  17.       Height          =   315
  18.       Left            =   0
  19.       TabIndex        =   2
  20.       Top             =   5475
  21.       Width           =   7905
  22.       _version        =   65536
  23.       _extentx        =   13944
  24.       _extenty        =   556
  25.       _stockprops     =   15
  26.       caption         =   "  No Server Connected"
  27.       backcolor       =   12632256
  28.       bevelouter      =   1
  29.       alignment       =   1
  30.    End
  31.    Begin Threed.SSPanel ToolBar 
  32.       Align           =   1  'Align Top
  33.       Height          =   435
  34.       Left            =   0
  35.       TabIndex        =   0
  36.       Top             =   0
  37.       Width           =   7905
  38.       _version        =   65536
  39.       _extentx        =   13944
  40.       _extenty        =   767
  41.       _stockprops     =   15
  42.       backcolor       =   12632256
  43.       bevelouter      =   0
  44.       outline         =   -1  'True
  45.       Begin Threed.SSCommand bDevice 
  46.          Height          =   375
  47.          Left            =   1200
  48.          TabIndex        =   4
  49.          Top             =   30
  50.          Width           =   375
  51.          _version        =   65536
  52.          _extentx        =   661
  53.          _extenty        =   661
  54.          _stockprops     =   78
  55.          forecolor       =   8421504
  56.          enabled         =   0   'False
  57.          bevelwidth      =   1
  58.          roundedcorners  =   0   'False
  59.          outline         =   0   'False
  60.          picture         =   "SQLPDBA.frx":030A
  61.       End
  62.       Begin Threed.SSCommand bDB 
  63.          Height          =   375
  64.          Left            =   810
  65.          TabIndex        =   3
  66.          Top             =   30
  67.          Width           =   375
  68.          _version        =   65536
  69.          _extentx        =   661
  70.          _extenty        =   661
  71.          _stockprops     =   78
  72.          enabled         =   0   'False
  73.          bevelwidth      =   1
  74.          roundedcorners  =   0   'False
  75.          outline         =   0   'False
  76.          picture         =   "SQLPDBA.frx":085C
  77.       End
  78.       Begin Threed.SSCommand bConnect 
  79.          Height          =   375
  80.          Left            =   60
  81.          TabIndex        =   1
  82.          Top             =   30
  83.          Width           =   375
  84.          _version        =   65536
  85.          _extentx        =   661
  86.          _extenty        =   661
  87.          _stockprops     =   78
  88.          bevelwidth      =   1
  89.          roundedcorners  =   0   'False
  90.          outline         =   0   'False
  91.          picture         =   "SQLPDBA.frx":096E
  92.       End
  93.    End
  94.    Begin VB.Menu mfile 
  95.       Caption         =   "&File"
  96.       Begin VB.Menu mconnect 
  97.          Caption         =   "&Connect"
  98.       End
  99.       Begin VB.Menu mdisconnect 
  100.          Caption         =   "&Disconnect!"
  101.          Enabled         =   0   'False
  102.       End
  103.       Begin VB.Menu mexit 
  104.          Caption         =   "E&xit"
  105.       End
  106.    End
  107.    Begin VB.Menu mmanage 
  108.       Caption         =   "&Manage"
  109.       Begin VB.Menu mdevices 
  110.          Caption         =   "&Devices"
  111.       End
  112.       Begin VB.Menu mdatabases 
  113.          Caption         =   "Data&bases"
  114.          Begin VB.Menu mdblist 
  115.             Caption         =   "&List"
  116.          End
  117.          Begin VB.Menu mbackup 
  118.             Caption         =   "&Backup"
  119.          End
  120.       End
  121.       Begin VB.Menu d11 
  122.          Caption         =   "-"
  123.       End
  124.       Begin VB.Menu mobjects 
  125.          Caption         =   "Database &Objects"
  126.       End
  127.    End
  128.    Begin VB.Menu mwindow 
  129.       Caption         =   "&Window"
  130.       Begin VB.Menu marrange 
  131.          Caption         =   "&Cascade"
  132.       End
  133.       Begin VB.Menu mtile 
  134.          Caption         =   "Tile"
  135.          Begin VB.Menu marrange1 
  136.             Caption         =   "&Horizontally"
  137.          End
  138.          Begin VB.Menu marrange2 
  139.             Caption         =   "&Vertically"
  140.          End
  141.       End
  142.       Begin VB.Menu marrange3 
  143.          Caption         =   "&Arrange Icons"
  144.       End
  145.       Begin VB.Menu d12 
  146.          Caption         =   "-"
  147.       End
  148.       Begin VB.Menu mwin 
  149.          Caption         =   ""
  150.          WindowList      =   -1  'True
  151.       End
  152.    End
  153.    Begin VB.Menu mhelp 
  154.       Caption         =   "&Help"
  155.       Begin VB.Menu mabout 
  156.          Caption         =   "&About"
  157.       End
  158.    End
  159. Attribute VB_Name = "SQLPDBA"
  160. Attribute VB_Creatable = False
  161. Attribute VB_Exposed = False
  162. Dim CurrentType As Integer
  163. Private Sub mabout_Click()
  164. fAbout.Show 1
  165. End Sub
  166. Private Sub marrange_Click()
  167. SQLPDBA.Arrange 0
  168. End Sub
  169. Private Sub marrange1_Click()
  170. SQLPDBA.Arrange 1
  171. End Sub
  172. Private Sub marrange2_Click()
  173. SQLPDBA.Arrange 2
  174. End Sub
  175. Private Sub marrange3_Click()
  176. SQLPDBA.Arrange 3
  177. End Sub
  178. Private Sub mbackup_Click()
  179. Backup.Show 1
  180. End Sub
  181. ' Dim OServer As New SQLOLE.SQLServer
  182. Private Sub mconnect_Click()
  183. ' connection dialog
  184. fconnect.Show 1
  185. End Sub
  186. Private Sub mdblist_Click()
  187. ' database Chart MDI
  188. DBMDI.Show
  189. End Sub
  190. Private Sub mdevices_Click()
  191. DevMDI.Show
  192. End Sub
  193. Private Sub MDIForm_Load()
  194. SQLConnected = False    ' not connected yet
  195. SetDisconnectButtons
  196. End Sub
  197. Private Sub MDIForm_Terminate()
  198. 'disconnect from the server if connected
  199. If SQLConnected = True Then
  200.     OServer.DisConnect
  201.     SQLConnected = False
  202.     SetDisconnectButtons
  203. End If
  204. Unload SQLPDBA          ' close app
  205. End Sub
  206. Private Sub mdisconnect_Click()
  207. If SQLConnected = True Then         ' disconnect
  208.     OServer.DisConnect              ' disconnect method
  209.     SQLConnected = False
  210.     StatusBar.Caption = "Not Connected"
  211.     SetDisconnectButtons
  212.     Unload DBMDI
  213.     Unload DevMDI
  214.     Unload ObjMDI
  215.     SQLPDBA.bDB.Enabled = False
  216.     SQLPDBA.bDevice.Enabled = False
  217.     SQLPDBA.bDevice.Enabled = False
  218.     SQLPDBA.bConnect.Enabled = True
  219. End If
  220. End Sub
  221. Private Sub mexit_Click()
  222. ' disconnect from the server
  223. If SQLConnected = True Then
  224.     OServer.DisConnect          ' disconnect
  225.     SQLConnected = False
  226.     SetDisconnectButtons
  227. End If
  228. Unload SQLPDBA                  ' close app
  229. End Sub
  230. Private Sub bConnect_Click()
  231. ' connection dialog
  232. fconnect.Show 1                 ' show Connect dialog
  233. End Sub
  234. Private Sub bDB_Click()
  235. DBMDI.Show                      ' Display Database Chart MDI
  236. End Sub
  237. Private Sub bDevice_Click()
  238. DevMDI.Show                     ' Display Device Chart MDI
  239. End Sub
  240. Public Sub SetConnectButtons()
  241.     mconnect.Enabled = False    ' disable 'connect' menu
  242.     mdisconnect.Enabled = True  ' enable 'disconnect' menu
  243. '    mLogins.Enabled = True
  244.     mdevices.Enabled = True
  245.     mdatabases.Enabled = True
  246.     mObjects.Enabled = True
  247. End Sub
  248. Public Sub SetDisconnectButtons()
  249.     mconnect.Enabled = True    ' disable 'connect' menu
  250.     mdisconnect.Enabled = False  ' enable 'disconnect' menu
  251. '    mLogins.Enabled = False
  252.     mdevices.Enabled = False
  253.     mdatabases.Enabled = False
  254.     mObjects.Enabled = False
  255. End Sub
  256. Private Sub mObjects_Click()
  257. ObjMDI.Show
  258. End Sub
  259. Private Sub Picture1_Click()
  260. End Sub
  261. Private Sub SSCommand1_Click()
  262.     On Error Resume Next
  263.    Set MyServer1 = CreateObject("sqlole.SQLServer")  ' Create a SQL Server Object
  264.    MyServer1.Connect "wind2xs", "sa", ""            ' Connect to the SQL Server
  265.        If Err <> 0 Then    ' errors?
  266.           MsgBox Err.Description + " (Press F1 for Help)", 16, Err.Source & " Error", _
  267.           Err.HelpFile, Err.HelpContext
  268.           MousePointer = 0
  269.           Exit Sub
  270.     End If
  271. ' you can add additional servers to the collection
  272.   Set MyServer2 = CreateObject("sqlole.SQLServer")  ' Create a SQL Server Object
  273.   MyServer2.Connect "kclaptop", "sa", ""            ' Connect to the SQL Server
  274.        
  275.        If Err <> 0 Then    ' errors?
  276.           MsgBox Err.Description + " (Press F1 for Help)", 16, Err.Source & " Error", _
  277.           Err.HelpFile, Err.HelpContext
  278.           MousePointer = 0
  279.           Exit Sub
  280.     End If
  281.   On Error GoTo 0
  282.    IRow = 2
  283. ' ==== Loop through the collection of SQLServers ===========
  284. ' Set MyServer = CreateObject("sqlole.SQLServer")
  285.  MsgBox Chr$(SQLServers.Count) + " servers "
  286.  For Each MyServer In SQLOLE.Application.SQLServers
  287.    MsgBox "          Working on " + MyServer.Name + "            "
  288.    ICol = 2
  289. ' ==== Loop through the collection of Databases on each SQLServer ===========
  290.    Dim MyDatabase As Object
  291.    For Each MyDatabase In MyServer.Databases
  292.        IRow = IRow + 1
  293.     MsgBox MyDatabase.Name
  294. '       ActiveSheet.Cells(IRow, 1).Value = MyServer.Name + "." + MyDatabase.Name
  295. '       ActiveSheet.Cells(IRow, 2).Value = 0 ' table count
  296.        ICol = 2
  297.      
  298. ' ==== Loop through the collection of Tables on each Database ===========
  299.       For Each MyTable In MyDatabase.Tables
  300.         ICol = ICol + 1
  301. '        MyTable.UpdateStatistics           ' update stats / all indexes
  302. '        ActiveSheet.Cells(IRow, ICol).Value = MyTable.Name
  303. '        ActiveSheet.Cells(IRow, 2).Value = ActiveSheet.Cells(IRow, 2).Value + 1
  304.       Next
  305.    Next
  306.    MyServer.DisConnect  'Disconnect from the server
  307.    IRow = IRow + 1
  308.  Next
  309. End Sub
  310.