home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / SQLNS / vb / dbprop / dbprop.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-06-01  |  2.5 KB  |  66 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "SQL Namespace Demo Application"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "Demo Time !"
  14.       Height          =   435
  15.       Left            =   1785
  16.       TabIndex        =   0
  17.       Top             =   1365
  18.       Width           =   1170
  19.    End
  20. Attribute VB_Name = "Form1"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = False
  23. Attribute VB_PredeclaredId = True
  24. Attribute VB_Exposed = False
  25. ' dbprop - display Database Properties Dialog using SQL Namespace
  26. Option Explicit
  27. Dim objSQLNS As SQLNamespace
  28. Dim hArray(10) As Long
  29. Private Sub Command1_Click()
  30.     On Error GoTo ErrHandler
  31.     ' get first level server->databases
  32.     hArray(1) = objSQLNS.GetFirstChildItem(hArray(0), SQLNSOBJECTTYPE_DATABASES)
  33.     ' get second level server->databases->database('pubs')
  34.     hArray(2) = objSQLNS.GetFirstChildItem(hArray(1), SQLNSOBJECTTYPE_DATABASE, "pubs")
  35.     ' get a SQLNamespaceObject to execute commands against on the wanted level
  36.     Dim objSQLNSObj As SQLNamespaceObject
  37.     Set objSQLNSObj = objSQLNS.GetSQLNamespaceObject(hArray(2))
  38.     ' execute the command (in this case by name)
  39.     objSQLNSObj.Commands("Properties").Execute
  40. Cleanup:
  41.     Set objSQLNSObj = Nothing
  42.     Exit Sub
  43. ErrHandler:
  44.     MsgBox Err.Description & " " & Err.Number, vbOKOnly, "Error"
  45.     GoTo Cleanup
  46. End Sub
  47. Private Sub Form_Load()
  48.     On Error GoTo ErrHandler
  49.     ' initialize the SQL Namespace (only once)
  50.     Set objSQLNS = New SQLNamespace
  51.     objSQLNS.Initialize "SQL Name Space Tester", SQLNSRootType_Server, "Server=.;UID=sa;pwd=;", hWnd
  52.     ' get a root object of type Server and walk down the hierarchy from there
  53.     hArray(0) = objSQLNS.GetRootItem
  54.     Exit Sub
  55. ErrHandler:
  56.     MsgBox Err.Description & " " & Err.Number, vbOKOnly, "Error"
  57.     ' if initializing SQL Namespace did not succeed, there is no use to go on
  58.     ' check if SQLNS.DLL is registered correctly (use regsvr32 SQLNS.DLL)
  59.     ' on maybe you could not connect, the demo looks for a local SQL Server
  60.     End
  61. End Sub
  62. Private Sub Form_Terminate()
  63.     ' destroy the SQL Namespace
  64.     Set objSQLNS = Nothing
  65. End Sub
  66.