home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "SQL Namespace Demo Application"
- ClientHeight = 3195
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 3195
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command1
- Caption = "Demo Time !"
- Height = 435
- Left = 1785
- TabIndex = 0
- Top = 1365
- Width = 1170
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' dbprop - display Database Properties Dialog using SQL Namespace
- Option Explicit
- Dim objSQLNS As SQLNamespace
- Dim hArray(10) As Long
- Private Sub Command1_Click()
- On Error GoTo ErrHandler
- ' get first level server->databases
- hArray(1) = objSQLNS.GetFirstChildItem(hArray(0), SQLNSOBJECTTYPE_DATABASES)
- ' get second level server->databases->database('pubs')
- hArray(2) = objSQLNS.GetFirstChildItem(hArray(1), SQLNSOBJECTTYPE_DATABASE, "pubs")
- ' get a SQLNamespaceObject to execute commands against on the wanted level
- Dim objSQLNSObj As SQLNamespaceObject
- Set objSQLNSObj = objSQLNS.GetSQLNamespaceObject(hArray(2))
- ' execute the command (in this case by name)
- objSQLNSObj.Commands("Properties").Execute
- Cleanup:
- Set objSQLNSObj = Nothing
- Exit Sub
- ErrHandler:
- MsgBox Err.Description & " " & Err.Number, vbOKOnly, "Error"
- GoTo Cleanup
- End Sub
- Private Sub Form_Load()
- On Error GoTo ErrHandler
- ' initialize the SQL Namespace (only once)
- Set objSQLNS = New SQLNamespace
- objSQLNS.Initialize "SQL Name Space Tester", SQLNSRootType_Server, "Server=.;UID=sa;pwd=;", hWnd
- ' get a root object of type Server and walk down the hierarchy from there
- hArray(0) = objSQLNS.GetRootItem
- Exit Sub
- ErrHandler:
- MsgBox Err.Description & " " & Err.Number, vbOKOnly, "Error"
- ' if initializing SQL Namespace did not succeed, there is no use to go on
- ' check if SQLNS.DLL is registered correctly (use regsvr32 SQLNS.DLL)
- ' on maybe you could not connect, the demo looks for a local SQL Server
- End
- End Sub
- Private Sub Form_Terminate()
- ' destroy the SQL Namespace
- Set objSQLNS = Nothing
- End Sub
-