by Bhuwan Chand Joshi (69 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 10th July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
SQL-NS Applications. Invoking a dialog box for data exporting
'Make a reference to Microsoft SQL Namespace Object Library
'Put a command button over the form
'Type the code below in the click event of Command Button
'Install SQL Server 7.0 in your machine
Private Sub Command1_Click()
On Error GoTo Err_Handler
Dim objSQLNS As SQLNamespace
Set objSQLNS = New SQLNamespace
objSQLNS.Initialize "SQL-NS Application", SQLNSRootType_Server, "Server=.;UID=sa;Password=;", hWnd
Dim hRootItem As Long
hRootItem = objSQLNS.GetRootItem
Dim hDatabases As Long
hDatabases = objSQLNS.GetFirstChildItem(hRootItem, 4)
Dim hDatabase As Long
hDatabase = objSQLNS.GetFirstChildItem(hDatabases, 5, "Pubs")
Dim objSQLNSobj As SQLNamespaceObject
Set objSQLNSobj = objSQLNS.GetSQLNamespaceObject(hDatabase)
objSQLNSobj.ExecuteCommandByID 60, hWnd, 1
Exit Sub
Err_Handler:
MsgBox Err.Description & " " & Err.Number, vbOKOnly, "SQL-NS"
End Sub