Programming SQL-NS Applications

The SQL Namespace (SQL-NS) object model includes objects, collections, properties, and methods used to write programs that can invoke SQL Server Enterprise Manager user interface components. SQL-NS objects are 32-bit Component Object Model (COM) objects for the Microsoft® Windows NT® 4.0, Microsoft Windows® 2000, Microsoft Windows 95, and Microsoft Windows 98 operating systems.

See Also

Scripting Data Access Controls in Internet Explorer


Getting Started with SQL-NS

SQL Namespace (SQL-NS) is a set of COM interfaces that allow a Microsoft® Visual Basic® or C++ application to invoke wizards, property sheets, dialog boxes and other SQL Server Enterprise Manager components. This layer complements the SQL Distributed Management Objects (SQL-DMO) layer of COM objects that was introduced in Microsoft SQL Server™ version 6.0. SQL-NS is layered on SQL-DMO.


SQL-NS Syntax Conventions

SQL-NS programming documentation uses the following conventions to distinguish elements of text.

Convention | Used for
UPPERCASE | Statements, macro names, and terms used at the operating system level.
monospace | Sample command lines and program code.
italic | Information that the user or the application must provide.
bold | SQL-NS component objects; object events, methods or properties; data types; and other syntax that must be typed exactly as shown.


Installing SQL-NS

All required SQL-NS components are installed as part of a Microsoft® SQL Server™ 2000 server installation. SQL-NS is implemented in a single dynamic-link library (DLL). You may develop SQL-NS applications on either a client or a server. When using an OLE Automation controller as a development platform, such as Microsoft Visual Basic®, no additional files are required. Application development using C or C++ requires the SQL-NS header files.

SQL-NS sample applications, which provide additional reference material for SQL-NS application development, are included with SQL Server.

Directory | File | Description
C:\Program Files\ Microsoft SQL Server\80\Tools\Binn | Sqlns.dll | DLL implementing SQL-NS objects.
C:\Program Files\ Microsoft SQL Server\80\Tools\Binn | Sqlns80.hlp | SQL-NS help file used within the development environment to provide context sensitive help about SQL-NS objects, properties and methods.
C:\Program Files\ Microsoft SQL Server\80\Tools\Binn\Resources\xxxx | Sqlns.rll | Localized resource file. The resource directory varies based on the national language of the installed SQL Server client or server. For example, the directory 1033 is a decimal representation of the language identifier 0X0409, which indicates English, U.S.
C:\Program Files\ Microsoft SQL Server\80\Tools\Devtools\Include | Sqlnsx.h | C/C++ header file containing SQL-NS member function prototypes, enumerated data types, and macros.
C:\Program Files\ Microsoft SQL Server\80\Tools\Devtools\Include | Sqlnsdef.h | C/C++ header file containing SQL-NS interface and class identifiers.
C:\Program Files\ Microsoft SQL Server\80\Tools\Devtools\Samples\Sqlns | ALL | Sample applications illustrating SQL-NS use.

To register the SQL-NS components on a client computer

  • From C:\Program Files\Microsoft SQL Server\80\Tools\Binn\Resources\<language> directory, execute:
    \Program Files\Microsoft SQL Server\80\Tools\Binn\REGSVR32 SQLNS.RLL
  • From any directory, execute:
    C:\Program Files\Microsoft SQL Server\80\Tools\Binn\REGSVR32.EXE

C:\Program Files\Microsoft SQL Server\80\Tools\Binn\resources\1033\SQLNS.DLL


SQL-NS Object Model


Using SQL-NS to Invoke SQL Server Enterprise Manager Components

The main SQL-NS interface is the SQLNamespace object, which enumerates the objects in the namespace. Individual objects are identified by the HSQLNSITEM handle. A SQLNamespaceObject interface can be obtained for this handle by calling the GetSQLNamespaceObject method.

The steps to invoke a user interface component are:

  1. Create the SQLNamespace object.

    Visual Basic

    Dim oSQLNS As SQLNamespace
Set oSQLNS = New SQLNamespace
' or using late binding
Dim oSQLNS As Object
Set oSQLNS = CreateObject("SQLNS.SQLNamespace")

    Visual C++

    ISQLNamespace * pNS = NULL;
CoInitialize(NULL);
CoCreateInstance(CLSID_SQLNamespace, NULL, LSCTX_INPROC_SERVER,      IID_ISQLNamespace, (LPVOID*)&pNS);
  2. Call ISQLNamespace::Initialize to initialize the namespace. This is the first action required after the object is declared, and it only needs to be called once for the lifetime of the SQLNamespace object. The namespace can be initialized at one of four different starting points (SQLNSRootType) in the namespace tree. The four SQLNSRootType constants are:
    • SQLNSRootType_DefaultRoot

    • SQLNSRootType_ServerGroup

    • SQLNSRootType_Server

    • SQLNSRootType_Database

    The first two constants, SQLNSRootType_DefaultRoot and SQLNSRootType_ServerGroup, retrieve their connection information from the registration information of SQL Server Enterprise Manager. Because this depends on a user's individual configuration, it is not recommended that an application use these two SQLNSRootType constants as a starting point. Instead, an application should use SQLNSRootType_Server, or SQLNSRootType_Database, because they give you complete control over the destination without having to depend on an individual user's SQL Server Enterprise Manager configuration.

  3. Pass a connection string as a parameter for the Initialize method. The connection string is almost identical to an ODBC connection string. The parts of the connection string are:
    • Server=MyServer;

    • SrvGrp=SQL Server Group;

    • UID=sa;

    • PWD=;

    • Trusted_Connection=Yes;

    • Database=pubs;

    If ROOTTYPE is SQLNSRootType_DefaultRoot, no connection string is required because all necessary information is retrieved from the SQL Server Enterprise Manager registration information on the local computer. If ROOTTYPE is SQLNSRootType_ServerGroup, the connection string only needs to contain the SvrGrp=SQL Server Group entry, because all other information is retrieved from SQL Server Enterprise Manager registry settings on the local computer. If SQLNSRootType_Server is used, an application must specify a complete connection string because no SQL Server Enterprise Manager registration information is available. The complete initialization and the connection string should look like this:

    Visual Basic

    ' Initialize root object
eSQLNSRootType = SQLNSRootType_Server
strConnectString = String(255, 0)
strConnectString = "Server=MYSERVER;Trusted_Connection=Yes;"
strAppName = "SQLNS Application; "
objSQLNS.Initialize strAppName, eSQLNSRootType, Str(strConnectString), hWnd
If objSQLNS Is Nothing Then
    MsgBox "SQLNamespace could not be initiated. Terminating.",  vbOKOnly, "Error"
End If

    Visual C++

    V_BSTR(&var) = SysAllocString(L"Server=.;Trusted_Connection=Yes;");
pNS->Initialize(L"SQLNSX Test App", SQLNSRootType_Server, &var, NULL);

'If the ROOTTYPE is SQLNSRootType_Database, add
'Database=pubs;
'to the connectstring. Otherwise, the connectstring is the same.
  4. Traverse the hierachy by establishing a root node in the hierarchy using a call to the ISQLNamespace::GetRootItem method. This root item is of the same type specified in the call to the Initialize method.

    Visual Basic

    Dim hRootItem As Long
hRootItem = objSQLNS.GetRootItem

    All HSQLNSITEM types are stored as Long in Microsoft® Visual Basic®. When a HSQLNSITEM is zero after an assignment, an error occurred. A good practice is to check for a zero HSQLNSITEM handle in your debug build by using asserts like this:

    Debug.Assert hRootItem = 0

    To test whether the object type of hRootItem is the same as the root type passed in to call to Initialize, an application can call objSQLNS.GetType(hRootItem) which returns the object type.

    Visual C++

    HSQLNSITEM hServer;
pNS->GetRootItem(&hServer);
assert (hServer);
  5. Walk the hierachy by calling the ISQLNamespace::GetChildItem method until the application reaches the required destination. For example, to invoke the Properties dialog box for dbo in the master database:

    Visual Basic

    Dim hRootItem As Long
Dim hDatabases As Long
Dim hDatabase As Long
Dim hUsers As Long
Dim hUser As Long
hRootItem = objSQLNS.GetRootItem
hDatabases = objSQLNS.GetFirstChildItem(hRootItem, _ SQLNSOBJECTTYPE_DATABASES)
hDatabase = objSQLNS.GetFirstChildItem(hDatabases, _SQLNSOBJECTTYPE_DATABASE, "master")
hUsers = objSQLNS.GetFirstChildItem(hDatabase, _SQLNSOBJECTTYPE_DATABASE_USERS)
hUser = objSQLNS.GetFirstChildItem(hUsers, _SQLNSOBJECTTYPE_DATABASE_USER, "dbo")

    Visual C++

    HSQLNSITEM hServer, hDBs, hDB, hUsers, hUser;
pNS->GetRootItem(&hServer);
pNS->GetFirstChildItem(hServer, SQLNSOBJECTTYPE_DATABASES, NULL, &hDBs);
pNS->GetFirstChildItem(hDBs, SQLNSOBJECTTYPE_DATABASE, L"pubs", &hDB);
pNS->GetFirstChildItem(hDB, SQLNSOBJECTTYPE_DATABASE_USERS, NULL, &hUsers);
pNS->GetFirstChildItem(hUsers, SQLNSOBJECTTYPE_DATABASE_USER, L"dbo", &hUser);
  6. Create a SQLNamespaceObject object to allow the user to execute commands that invoke the required user interface components:

    Visual Basic

    Dim objSQLNSObj As SQLNS.SQLNamespaceObject
Set objSQLNSObj = objSQLNS.GetSQLNamespaceObject(hUser)

    Visual C++

    ISQLNamespaceObject* pObjUser = NULL;
pNS->GetSQLNamespaceObject(hUser, &pObjUser);

    You can enumerate all available commands on SQLNamespaceObject objects by iterating through the Commands collection.

  7. Execute a command on the SQLNamespaceObject object just created, which invokes the user interface component. An application can execute a command by name or ID. The latter is the prefered method because it is independent of the language of the system. To execute by name, pass the command by calling the ExecuteCommandByName method:
    objSQLNSObj.ExecuteCommandByName "Properties", hWnd,     SQLNamespace_PreferModal

    The other two parameters are the handle to the parent window, and the window modality. The modality can be one of three values that indicate the preferred modality:

    • SQLNamespace_DontCare

    • SQLNamespace_PreferModal

    • SQLNamespace_PreferModeless

    Note The SQL Namespace can overrule the requested modality due to default characteristics of the dialog box invoked.

    The preferred way to execute a command by ID is to passing in a constant that indentifies the command:

    objSQLNSObj.ExecuteCommandByID SQLNS_CmdID_PROPERTIES, hWnd, SQLNamespace_PreferModal

    An application can also iterate through the Commands collection on the SQLNamespaceObject object. Each item of the collection represents a SQLNamespaceCommand, which has an Execute method.

See Also

SQL-NS Reference


Handling SQL-NS Errors

When using SQL Namespace to invoke SQL Server Enterprise Manager user interface components, an administrative application should guide users, steamlining tasks and limiting the range of possible errors. Nonetheless, errors can occur and a SQL-NS application should supply error handling code to prevent abnormal termination.

Microsoft Visual Basic®/ActiveX® script supports error traps (error handlers) created using the ON ERROR statement. SQL-NS supports the Visual Basic Err object, allowing application error handlers to respond intelligently to errors raised.

In C++ applications, check the return value of each function. Every COM function returns an HRESULT value indicating success or failure. If the HRESULT return value is not SUCCESS, create a COM error handling object like this.

void ReportError()
{
   OLECHAR szMsg[512];
   LPERRORINFO pErrorInfo;

   szMsg[0] = 0;
   if ((SUCCEEDED(GetErrorInfo(0, &pErrorInfo)))
      && (pErrorInfo != NULL))
   {
      BSTR bstrDesc = NULL;
      BSTR bstrSource = NULL;

      pErrorInfo->GetDescription(&bstrDesc);
      pErrorInfo->GetSource(&bstrSource);

      if (bstrDesc && wcslen(bstrDesc))
      {
         wcscat(szMsg, L"\r\n\r\n");
         if (bstrSource && wcslen(bstrSource))
         {
            wcscat(szMsg, L"[");
            wcscat(szMsg, bstrSource);
            wcscat(szMsg, L"] - ");
         }
         wcscat(szMsg, bstrDesc);
      }
      if (bstrDesc)
         SysFreeString(bstrDesc);
      if (bstrSource)
         SysFreeString(bstrSource);
      pErrorInfo->Release();
   }

   MessageBoxW(NULL, szMsg, L"Error", MB_OK);

}


SQL-NS Reference

SQL Namespace objects are implemented in C:\Program Files\Microsoft SQL Server\80\Tools\Binn\Sqlns.dll and C:\Program Files\Microsoft SQL Server\80\Tools\Binn\Resources\1033\Sqlns.rll. (The resource directory varies depending on the Unicode collation locale for this instance. 1033 is the General Unicode collation.) Visual Basic applications must include a reference to the SQL-NS object to use early binding. The type library is implemented in the resource Library, Sqlns.rll. C++ applications must include Sqlnsx.h, which references Sqlnsdef.h or use the #import directive to import the type library located in the resource file Sqlns.rll. All interfaces described are automation-enabled dual interfaces.


SQL-NS Objects

SQL-NS exposes these objects:


SQLNamespace Object

The SQLNamespace object (in C++ ISQLNamespace) is the main interface and starting point for using SQL-NS objects.

Methods
GetChildrenCount Method | GetSQLDMOObject Method
GetFirstChildItem Method | GetSQLNamespaceObject Method
GetName Method | GetType Method
GetNextSiblingItem Method | Initialize Method
GetParentItem Method | Refresh Method
GetPreviousSiblingItem Method | SetLCID Method
GetRootItem Method |


SQLNamespaceCommand Object

The SQLNamespaceCommand object is the interface that implements the commands for a SQLNamespace object, which invokes user interface objects.

Properties
CommandID Property | Name Property
HelpString Property |

Methods


SQLNamespaceCommands Object

The SQLNamespaceCommands object is a collection object containing the commands (SQLNamespaceCommand objects) supported by a SQLNamespaceObject object.

Properties
Count Property

Methods
Item Method


SQLNamespaceObject Object

The SQLNamespaceObject object is the interface that represents a Microsoft® SQL Server™ 2000 Enterprise Manager user interface node in the hierarchy of SQL Namespace.

Properties

Methods


SQL-NS Properties

SQL-NS exposes these properties:

CommandID Property | HelpString Property
Commands Property | Name Property
Count Property | Type Property
Handle Property |


CommandID Property

The CommandID property returns the SQLNSCommandID value of a SQLNamespaceCommand object. SQLNSCommandID represents the command that invokes a user interface component on a SQLNamespaceObject object.

Applies To
SQLNamespaceCommand Object

Syntax

object.CommandID

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

SQLNSCommandID

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetCommandID(SQLNSCommandID *pRetVal) = 0;

Remarks

Not all SQLNSCommandID values are valid commands on a particular SQLNamespaceObject object. To verify that a command is valid, you must verify that the command is part of the Commands collection on the SQLNamespace object.


Commands Property

The Commands property returns the SQLNamespaceCommands collection object.

Applies To
SQLNamespaceObject Object

Syntax

object.Commands

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

SQLNamespaceCommands Object

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetCommands(ISQLNamespaceCommands *pRetVal);


Count Property

The Count property returns the number of SQLNamespaceCommand objects in the SQLNamespaceCommands collection object.

Applies To
SQLNamespaceCommands Object

Syntax

object.Count

Parts

collection

Expression that evaluates to an object in the Applies To list

Data Type

Long

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetCount(long *pRetVal);


Handle Property

The Handle property contains the value of the SQLNamespaceObject object handle.

Applies To
SQLNamespaceObject Object

Syntax

object.Handle

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

Long

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetHandle(HSQLNSITEM *pRetVal);


HelpString Property

The HelpString property returns a help string for the SQLNamespaceCommand object command.

Applies To
SQLNamespaceCommand Object

Syntax

object.HelpString

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

String

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetHelpString(BSTR *pRetVal);

Remarks

Because some SQLNSCommandID values are applicable to multiple SQLNamespaceObject objects, the help string return value can be very generic.


Name Property

The Name property returns the descriptive string displayed in the namespace hierarchy of objects and commands.

Applies To
SQLNamespaceCommand Object SQLNamespaceObject Object

Syntax

object.Name

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

String

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetName(BSTR *pRetVal);

Remarks

In the case of the SQLNamespaceCommand object, Name returns the name of the command. The value of Name can then be used as the parameter for the ExecuteCommandByName method on the SQLNamespaceObject object. On the SQLNamespaceObject object, it returns the name of the object.


Type Property

The Type property returns the SQLNamespaceObject object type as SQLNSObjectType.

Applies To
SQLNamespaceObject Object

Syntax

object.Type

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

SQLNSObjectType

Modifiable

Read-only

Prototype (C/C++)

HRESULT GetType(SQLNSObjectType *pRetVal);

Remarks

SQLNSObjectType is an enumeration containing all possible objects.


SQL-NS Methods

SQL-NS exposes these methods:

Execute Method | GetPreviousSiblingItem Method
ExecuteCommandByID Method | GetRootItem Method
ExecuteCommandByName Method | GetSQLDMOObject Method
ExecuteWithParam Method | GetSQLNamespaceObject Method
GetChildrenCount Method | GetType Method
GetFirstChildItem Method | Initialize Method
GetName Method | Item Method
GetNextSiblingItem Method | Refresh Method
GetParentItem Method | SetLCID Method


Execute Method

The Execute method executes the command associated with the SQLNamespaceCommand object related to the user interface component associated with the command.

Applies To
SQLNamespaceCommand Object

Syntax

object.Execute(
[hWnd],
[modality])

Parts

object

Expression that evaluates to an object in the Applies To list

hWnd

Window handle

modality

Modality of the window

Prototype (C/C++)

HRESULT Execute(
long hwnd ,
SQLNSModality modality);

Remarks

The Execute method optionally provides a parent window. By default, the window handle specified in the Initialize method will be used. The modality parameter suggests preference in modality of the user interface. SQL Namespace, due to the modality of a specific user interface component, can overrule the requested modality. If there is no parent window handle specified during the Initialize call and the modality is SQLNamespace_PreferModal, the value of this parameter cannot be NULL.


ExecuteCommandByID Method

The ExecuteCommandByID method executes the command on the SQLNamespaceObject object identified by the CommandID parameter.

Applies To
SQLNamespaceObject Object

Syntax

object.ExecuteCommandByID(
CommandID,
[hWnd],
[modality])

Parts

object

Expression that evaluates to an object in the Applies To list

CommandID

Command ID

hWnd

Parent window handle

modality

Modality of the window

Prototype (C/C++)

HRESULT ExecuteCommandByID(
SQLNSCommandID CommandID,
long hwnd,
SQLNSModality modality);

Remarks

The ExecuteCommandByID method optionally provides a parent window (by default, the parent window handle specified by the Initialize method) and suggests preference in modality of the user interface. ExecuteCommandByID is the preferred method for executing commands, because it is independent of the system language of the computer where the application runs.


ExecuteCommandByName Method

The ExecuteCommandByName method executes the command identified by the bstrCommand parameter.

Applies To
SQLNamespaceObject Object

Syntax

object.ExecuteCommandByName(
bstrCommand As String,
[hWnd] As Long,
[modality] As SQLNSModality)

Parts

object

Expression that evaluates to an object in the Applies To list

bstrCommand

Name of the command

hWnd

Parent window handle

modality

Modality of the window

Prototype (C/C++)

HRESULT ExecuteCommandByName(
BSTR bstrCommand,
long hwnd,
SQLNSModality modality);

Remarks

The ExecuteCommandByName method optionally provides a parent window (by default, the window specified by the Initialize method) and suggests preference in modality of the user interface. Calling ExecuteCommandByName will make an application dependent on the language of the system where the application runs. To avoid this behavior, call ExecuteCommandByID.


ExecuteWithParam Method

The ExecuteWithParam method executes the command associated with the SQLNamespaceCommand object, which is related to the user interface component associated with the command. A parameter can be passed with the command.

Applies To
SQLNamespaceCommand Object

Syntax

object.ExecuteWithParam(
[ hWnd ] ,
[ modality ] ,
[ pVarParam ] )

Parts

object

Expression that evaluates to an object in the Applies To list

hWnd

Long integer that specifies the parent window handle

modality

SQLNSModality constant that indicates modality type as described in Settings

pVarParam

Variant that contains the value to pass as a parameter

Settings

Set modality using these values.

Constant | Value | Description
SQLNamespace_DontCare | 0 | Default window behavior.
SQLNamespace_PreferModal | 1 | Modal window behavior (if available).
SQLNamespace_PreferModeless | 2 | Modeless window behavior (if available).

Prototype (C/C++)

HRESULT ExecuteWithParam(
long hwnd,
SQLNSModality modality,
LPVARIANT pVarParam)

Remarks

The ExecuteWithParam method optionally provides a parent window. By default, the window handle specified in the Initialize method will be used. The modality parameter suggests preference in modality of the user interface. SQL Namespace, due to the modality of a specific user interface component, can overrule the requested modality. If there is no parent window handle specified during the Initialize call and the modality is SQLNamespace_PreferModal, the value of this parameter cannot be NULL.

ExecuteWithParam extends the functionality of the Execute method by allowing an application to pass a parameter in the optional pVarParam parameter.


GetChildrenCount Method

The GetChildrenCount method retrieves the number of child members belonging to an item.

Applies To
SQLNamespace Object

Syntax

object.GetChildrenCount(
ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

Long

Prototype (C/C++)

HRESULT GetChildrenCount(
HSQLNSITEM ItemIn,
long *pRetVal);


GetFirstChildItem Method

The GetFirstChildren method retrieves the first child item, relative from the item in the SQL Namespace hierarchy, and optionally matchesthe object type or object name.

Applies To
SQLNamespace Object

Syntax

object.GetFirstChildItem(
ItemIn ,
[matchType] ,
[matchName])

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

matchType

Object type to match

matchName

Object name to match

Data Type

Long

Prototype (C/C++)

HRESULT GetFirstChildItem(
HSQLNSITEM ItemIn,
SQLNSObjectType matchType,
BSTR matchName,
HSQLNSITEM *pItemOut);


GetName Method

The GetName method retrieves the name of a member item.

Applies To
SQLNamespace Object

Syntax

object.GetName(
ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

String

Prototype (C/C++)

HRESULT GetName(
HSQLNSITEM ItemIn,
BSTR *pRetVal);


GetNextSiblingItem Method

The GetNextSiblingItem method retrieves the next sibling item, optionally matching the object type or object name.

Applies To
SQLNamespace Object

Syntax

object.GetNextSiblingItem(
ItemIn ,
[matchType] ,
[matchName])

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

matchType

Object type to match

matchName

Object name to match

Data Type

Long

Prototype (C/C++)

HRESULT GetNextSiblingItem(
HSQLNSITEM ItemIn,
SQLNSObjectType matchType,
BSTR matchName,
HSQLNSITEM *pItemOut);


GetParentItem Method

The GetParentItem method retrieves the parent item.

Applies To
SQLNamespace Object

Syntax

object.GetParentItem(
ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

Long

Prototype (C/C++)

HRESULT GetParentItem(
HSQLNSITEM ItemIn,
HSQLNSITEM *pItemOut);


GetPreviousSiblingItem Method

The GetPreviousSiblingItem method retrieves the previous sibling item, optionally matching the object type or object name.

Applies To
SQLNamespace Object

Syntax

object.GetPreviousSiblingItem(
ItemIn ,
[matchType] ,
[matchName])

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

matchType

Object type to match

matchName

Object name to match

Data Type

Long

Prototype (C/C++)

HRESULT GetPreviousSiblingItem(
HSQLNSITEM ItemIn,
SQLNSObjectType matchType,
BSTR matchName,
HSQLNSITEM *pItemOut);


GetRootItem Method

Retrieves the handle to the root item in the Namespace hierarchy. The root item is defined by the Initialize method.

Applies To
SQLNamespace Object

Syntax

object.GetRootItem()

Parts

object

Expression that evaluates to an object in the Applies To list

Data Type

Long

Prototype (C/C++)

HRESULT GetRootItem(
HSQLNSITEM *pItemOut);


GetSQLDMOObject Method

The GetSQLDMOObject method retrieves the SQL-DMO object associated with this item.

Applies To
SQLNamespace Object

Syntax

object.GetSQLDMOObject(
ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

Object

Prototype (C/C++)

HRESULT GetSQLDMOObject(
HSQLNSITEM ItemIn,
IDispatch **pRetVal);

Remarks

Not all items have associated SQL-DMO objects. If you want strong type checking for the SQL-DMO objects in Microsoft® Visual Basic®, reference the Microsoft SQL-DMO Object Library. To validate that the object type returned is correct, use the TypeOf method that every SQL-DMO object exposes. TypeOf returns a member of the SQLDMO_OBJECT_TYPE enumeration. If no object is associated with the SQLNamespace object, an empty object is returned (Object Is Nothing). In C++, use the IID_IV* (OLE Automation (VB/VBA) Dual Interfaces) instead of the IID_IW* - C++ Unicode interfaces, because the GetSQLDMOObject method returns an IDispatch pointer. Only the SQL-DMO SQLServer and Database objects are returned.


GetSQLNamespaceObject Method

The GetSQLNamespaceObject method retrieves the namespace interface for the item.

Applies To
SQLNamespace Object

Syntax

object.GetSQLNamespaceObject(
ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

SQLNamespaceObject

Prototype (C/C++)

HRESULT GetSQLNamespaceObject(
HSQLNSITEM ItemIn,
ISQLNamespaceObject **pRetVal);


GetType Method

Retrieves the object type (SQLNSObjectType) of the item.

Applies To
SQLNamespace Object

Syntax

object.GetType(
ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

SQLNSObjectType

Prototype (C/C++)

HRESULT GetType(
HSQLNSITEM ItemIn,
SQLNSObjectType *pRetVal);


Initialize Method

The Initialize method initializes the namespace, providing the name of client application.

Applies To
SQLNamespace Object

Syntax

object.Initialize(
bstrAppName ,
[rootType] ,
[pRootInfo] ,
[hWnd])

Parts

object

Expression that evaluates to an object in the Applies To list

bstrAppName

Name of the client application

rootType

Type of object to set as root

pRootInfo

Root information

hWnd

Window handle

Remarks

Optionally, provides the default parent window for the user interface, and also a nondefault root of the namespace. For more information about the connectstring, see Programming SQL-NS Applications.

Prototype (C/C++)

HRESULT Initialize(
BSTR bstrAppName,
SQLNSRootType rootType,
VARIANT * pvarRootInfo,
long hWnd);


Item Method

The Item method returns the SQLNamespaceCommand object in the collection based on the specified index parameter.

Applies To
SQLNamespaceCommands Object

Syntax

object.Item(
Index)

Parts

object

Expression that evaluates to an object in the Applies To list

Index

Order of an object in the SQLNamespaceCommands collection

Data Type

SQLNamespaceCommand

Prototype (C/C++)

HRESULT Item(
ISQLNamespaceCommand *pRetVal);

Remarks

The index is 1-based.


Refresh Method

The Refresh method refreshes the console tree under the specified node.

Applies To
SQLNamespace Object

Syntax

object.Refresh(ItemIn)

Parts

object

Expression that evaluates to an object in the Applies To list

ItemIn

Handle to the item in the namespace hierarchy

Data Type

None

Prototype (C/C++)

HRESULT Refresh(
HSQLNSITEM ItemIn);


SetLCID Method

The SetLCID method sets the locale ID for SQL Namespace.

Applies To
SQLNamespace Object

Syntax

object.SetLCID(
lLCID)

Parts

object

Expression that evaluates to an object in the Applies To list

lLCID

Locale ID of SQL Namespace

Data Type

None

Prototype (C/C++)

HRESULT SetLCID(
long lcid);


SQL-NS Constants

Enumerated data types are package constants defined in Sqlns.rll. They are used as parameters and return values in SQL-NS package properties and methods.

SQL-NS exposes these constants:

SQLNSCommandID | SQLNSObjectType
SQLNSErrors | SQLNSRootType
SQLNSModality |


SQLNSCommandID

SQLNSCommandID constants specify SQL-NS command IDs available in the SQLNamespace object.

Constant | Value | Command
SQLNS_CmdID_AGENT_ERROR_DETAILS | 76 | Error Details Opens the Agent Error Details dialog box for the specified replication agent.
SQLNS_CmdID_AGENT_HISTORY | 77 | Agent History Opens the Agent History dialog box for the specified replication agent.
SQLNS_CmdID_DATABASE_BACKUP | 80 | Back up Database Opens the SQL Server Backup dialog box.
SQLNS_CmdID_DATABASE_RESTORE | 81 | Restore Database Opens the Restore Database dialog box.
SQLNS_CmdID_DATABASE_SHRINKDB | 82 | Shrink Database Opens the Shrink Database dialog box.
SQLNS_CmdID_DEFECT | 56 | Defect.
SQLNS_CmdID_DELETE | 17 | Delete Deletes the specified item.
SQLNS_CmdID_DTS_EXPORT | 60 | Data Export Starts the DTS Export Wizard.
SQLNS_CmdID_DTS_IMPORT | 59 | Data Import Starts the DTS Import Wizard.
SQLNS_CmdID_DTS_RUN | 61 | Run Package Executes a DTS package.
SQLNS_CmdID_EDIT_SERVER | 43 | Edit Server Registration dialog box.
SQLNS_CmdID_ENLIST | 55 | Enlist Starts the Make This a Target Server Wizard.
SQLNS_CmdID_ENLIST_REG_SERVERS | 62 | Enlist Registered Servers.
SQLNS_CmdID_EXPORT_JOB | 57 | Generates a script file for the selected Microsoft® SQL Server™ 2000 Agent job.
SQLNS_CmdID_GENERATE_SCRIPTS | 79 | Generate Scripts Opens the Generate SQL Scripts dialog box.
SQLNS_CmdID_JOB_HISTORY | 40 | Displays the job history information for a selected SQL Server Agent job.
SQLNS_CmdID_JOB_PROPERTIES (was SQLNS_CmdID_JOB_STEPS) | 48 | Displays the property dialog box for a selected SQL Server Agent job.
SQLNS_CmdID_JOB_START | 39 | Starts a selected SQL Server Agent job.
SQLNS_CmdID_JOB_STOP | 41 | Stops the selected SQL Server Agent job, if currently running.
SQLNS_CmdID_JOBSERVER_ERRORLOG | 38 | Display Error log Opens the SQL Server Agent Error Log dialog box.
SQLNS_CmdID_JOBSERVER_TARGET_SERVERS | 42 | Target Servers Opens the Target Servers dialog box.
SQLNS_CmdID_MULTI_SERVER_JOB_STATUS | 58 | Reserved.
SQLNS_CmdID_NEW_ALERT | 20 | New Alert Opens the New Alert Properties dialog box.
SQLNS_CmdID_NEW_BACKUPDEVICE | 36 | New Backup Device Opens the Backup Device Properties - New Device dialog box.
SQLNS_CmdID_NEW_DATABASE | 23 | New Database Opens the Database Properties dialog box.
SQLNS_CmdID_NEW_DATABASE_ROLE | 33 | New Database Role Opens the Database Role Properties - New Role dialog box.
SQLNS_CmdID_NEW_DBUSER | 35 | New Database User Opens the Database User Properties - New User dialog box.
SQLNS_CmdID_NEW_DEFAULT | 29 | New Default Opens the Default Properties dialog box.
SQLNS_CmdID_NEW_DIAGRAM | 32 | Does not display a dialog box (internal use only).
SQLNS_CmdID_NEW_EXTENDED_STORED_PROCEDURE | 27 | Add extended stored procedure (master only).
SQLNS_CmdID_NEW_JOB | 19 | Add new SQL Server Agent job.
SQLNS_CmdID_NEW_LOGIN | 34 | New Login.
SQLNS_CmdID_NEW_OPERATOR | 21 | New Operator Opens the New Operator Properties dialog box.
SQLNS_CmdID_NEW_PUBLICATION | 69 | New Publication Starts the Create Publication Wizard.
SQLNS_CmdID_NEW_REMOTE_SERVER | 22 | Add Remote Server.
SQLNS_CmdID_NEW_RULE | 28 | New Rule Opens the Rule Properties dialog box.
SQLNS_CmdID_NEW_SERVER | 18 | Add Server to a Server Group (only on default root or server group root level).
SQLNS_CmdID_NEW_SERVER_GROUP | 31 | New Server Group (only on default_root root level).
SQLNS_CmdID_NEW_STORED_PROCEDURE | 26 | New Stored Procedure Opens the Stored Procedure Properties - New Stored Procedure dialog box.
SQLNS_CmdID_NEW_SUBSCRIPTION | 72 | New Pull Subscription Starts the Pull Subscription Wizard.
SQLNS_CmdID_NEW_TABLE | 24 | Does not display a dialog box (internal use only).
SQLNS_CmdID_NEW_TRACE | 86 | New trace
SQLNS_CmdID_NEW_UDDT | 30 | New User Defined Data Type Opens the User-Defined Data Type Properties dialog box.
SQLNS_CmdID_NEW_UDF | 85 | New user-defined function
SQLNS_CmdID_NEW_VIEW | 25 | Does not display a dialog box (internal use only).
SQLNS_CmdID_OBJECT_DEPENDENCIES | 45 | Object Dependencies Opens the Dependencies dialog box.
SQLNS_CmdID_OBJECT_PERMISSIONS | 44 | Object Permissions Opens the Object Permissions dialog box.
SQLNS_CmdID_OPEN | 37 | Does not display a dialog box (internal use only).
SQLNS_CmdID_PROPERTIES | 16 | Properties Opens the Properties dialog box for the specified item.
SQLNS_CmdID_PUBLISHING_PROPERTIES | 83 | Publishing and Distribution Properties.
SQLNS_CmdID_PUSH_NEW_SUBSCRIPTION | 70 | New Pull Subscription Starts the Pull Subscription Wizard.
SQLNS_CmdID_REINIT_SUBSCRIPTION | 73 | Reinitialize Reinitializes a subscription.
SQLNS_CmdID_REPLICATION_CONFIGURE | 65 | Configure Publishing and Distribution Starts the Configure Publishing and Distribution Wizard.
SQLNS_CmdID_REPLICATION_SUBSCRIBE | 66 | Pull Subscription Opens the Pull Subscription dialog box.
SQLNS_CmdID_REPLICATION_UNINSTALL | 68 | Disable Publishing or Distribution.
SQLNS_CmdID_REPLICATION_PUBLISH | 64 | Publish and Push Subscription Opens the Create and Manage Publications dialog box.
SQLNS_CmdID_REPLICATION_RESOLVE_CONFLICTS | 71 | Resolve Conflicts.
SQLNS_CmdID_REPLICATION_SCRIPT | 67 | Create Replication Script.
SQLNS_CmdID_SECURITY_LIST | 78 | Manage SQL Server Security Opens the SQL Server Security dialog box.
SQLNS_CmdID_SERVER_CONFIGURATION | 54 | Does not display a dialog box (internal use only).
SQLNS_CmdID_SERVER_CONNECT | 53 | Reserved.
SQLNS_CmdID_SERVER_SECURITY | 52 | Server Security Starts the Create Login Wizard.
SQLNS_CmdID_STOP_SYNCHRONIZING | 75 | Stop Synchronizing Immediately stops synchronization of a subscription.
SQLNS_CmdID_SVC_PAUSE | 50 | Pause Service Pauses the specified service.
SQLNS_CmdID_SVC_START | 51 | Start Service Starts the specified service.
SQLNS_CmdID_SVC_STOP | 49 | Stop Service Stops the specified service.
SQLNS_CmdID_SYNCHRONIZE_NOW | 74 | Synchronize Now Immediately synchronizes a subscription.
SQLNS_CmdID_TABLE_INDEXES | 46 | Manage Indexes Opens the Manage Indexes dialog box.
SQLNS_CmdID_TABLE_TRIGGERS | 47 | Manage Triggers Opens the Trigger Properties dialog box.
SQLNS_CmdID_TOOLS_MAINT_PLAN | 63 | Database Maintenance Plan Starts the Database Maintenance Plan Wizard.
SQLNS_CmdID_WIZARD_INDEXTUNING | 9 | Index Tuning Wizard Starts the Index Tuning Wizard.
SQLNS_CmdID_WIZARD_ALERT | 10 | Create Alert Wizard Starts the Create Alert Wizard.
SQLNS_CmdID_WIZARD_BACKUP | 13 | Backup Wizard Starts the Create Database Backup Wizard.
SQLNS_CmdID_WIZARD_CREATEDB | 1 | Create Database Wizard Starts the Create Database Wizard.
SQLNS_CmdID_WIZARD_CREATEINDEX | 2 | Create Index Wizard Starts the Create Index Wizard.
SQLNS_CmdID_WIZARD_CREATEJOB | 5 | Create Job Wizard Starts the Create Job Wizard.
SQLNS_CmdID_WIZARD_CREATETRACE | 14 | Create Trace Wizard Starts the Create Trace Wizard.
SQLNS_CmdID_WIZARD_DTSEXPORT | 4 | Data Export Wizard Starts the DTS Export Wizard.
SQLNS_CmdID_WIZARD_DTSIMPORT | 3 | Data Import Wizard Starts the DTS Import Wizard.
SQLNS_CmdID_WIZARD_MAINTPLAN | 11 | Database Maintenance Plan Wizard Starts the Database Maintenance Plan Wizard.
SQLNS_CmdID_WIZARD_SECURITY | 6 | Security Wizard Starts the Create Login Wizard.
SQLNS_CmdID_WIZARD_SP | 7 | Create Stored Procedure Wizard Starts the Stored Procedure Wizard.
SQLNS_CmdID_WIZARD_VIEW | 8 | Create View Wizard Starts the Create View Wizard.
SQLNS_CmdID_WIZARD_WEBASST | 12 | Web Assistant Wizard Starts the Web Assistant Wizard.
SQLNS_CmdID_WIZARDS | 15 | Wizards Opens the Select Wizard dialog box.


SQLNSErrors

SQLNSErrors constants specify error ranges available to the SQLNamespace object.

Constant | Value | Description
SQLNS_E_Already_Initialized | 1005 | Initialize method was called more than one time.
SQLNS_E_DatabaseNotFound | 1019 | Specified database was not found.
SQLNS_E_ExternalError | 1100 | Error outside the scope of SQL-NS and SQL-DMO occurred.
SQLNS_E_InvalidCommandID | 1011 | Invalid command ID was specified in a call to ExecuteCommandByID.
SQLNS_E_InvalidCommandName | 1010 | Invalid command name was specified in a call to ExecuteCommandByName.
SQLNS_E_InvalidConnectString | 1016 | Connection string is invalid.
SQLNS_E_InvalidDBName | 1015 | Database name is invalid.
SQLNS_E_InvalidLoginInfo | 1014 | Login information is invalid.
SQLNS_E_InvalidObjectHandle | 1008 | Object handle is invalid due to specifying an invalid relationship or passing a null pointer.
SQLNS_E_InvalidRootInfo | 1012 | Connection string does not match with the root object specified.
SQLNS_E_InvalidRootType | 1006 | Nonmember of the current root type was specified.
SQLNS_E_InvalidServerName | 1013 | Invalid server name specified.
SQLNS_E_InvalidServerVersion | 1020 | Server specified must be running SQL Server 7.0.
SQLNS_E_NameDup | 1004 | Reserved.
SQLNS_E_NameNotFound | 1003 | Command name was not found in a call to ExecuteCommandByName.
SQLNS_E_NoDMOObject | 1009 | There is no underlying SQL-DMO object
SQLNS_E_NotImplemented | 1001 | SQL Namespace object not implemented.
SQLNS_E_OrdOutOfRange | 1002 | Call was made into a .dll where the ordinal does not exist.
SQLNS_E_RequireAppName | 1007 | Application name is required in a call to Initialize.
SQLNS_E_ServerNotFound | 1018 | Server name was not found when specifying SQLNSRootType_Server.
SQLNS_E_SrvGrpNotFound | 1017 | Server group was not found when specifying SQLNSRootType_ServerGroup.


SQLNSModality

SQLNSModality constants set the modality of the user interface component displayed.

Constant | Value | Description
SQLNamespace_DontCare | 0 | Default window behavior.
SQLNamespace_PreferModal | 1 | Modal window behavior if available.
SQLNamespace_PreferModeless | 2 | Modeless window behavior if available.


SQLNSObjectType

SQLNSObjectType constants specify object type definitions.

Constant | Value | Description
SQLNSOBJECTTYPE _DATABASE | 5 | Specific database, SQLNSRootType_Server\Databases\master.
SQLNSOBJECTTYPE_ALERT | 58 | SQLNSRootType_Server\Management\SQL Server Agent\Alerts\Demo: Full msdb log.
SQLNSOBJECTTYPE_ALERTS | 47 | SQLNSRootType_Server\Management\SQL Server Agent\Alerts.
SQLNSOBJECTTYPE_BACKUPDEVICE | 12 | Specific backup device.
SQLNSOBJECTTYPE_BACKUPDEVICES | 11 | Backup Devices.
SQLNSOBJECTTYPE_CURRENTACTIVITY | 95 | SQLNSRootType_Server\Management\Current Activity.
SQLNSOBJECTTYPE_CURRENTACTIVITY_LOCKEDOBJECT | 101 | SQLNSRootType_Server\Management\Current Activity\Locks\Object\master.
SQLNSOBJECTTYPE_CURRENTACTIVITY_LOCKEDOBJECT_INFO | 102 | SQLNSRootType_Server\Management\Current Activity\Locks\Object\master\1.
SQLNSOBJECTTYPE_CURRENTACTIVITY_LOCKEDOBJECTS | 100 | SQLNSRootType_Server\Management\Current Activity\Locks\Object.
SQLNSOBJECTTYPE_CURRENTACTIVITY_LOGIN | 97 | Reserved.
SQLNSOBJECTTYPE_CURRENTACTIVITY_PROCESSINFO | 98 | SQLNSRootType_Server\Management\Current Activity\Process Info.
SQLNSOBJECTTYPE_CURRENTACTIVITY_PROCESSINFO_INFO | 99 | SQLNSRootType_Server\Management\Current Activity\Process Info\1.
SQLNSOBJECTTYPE_CURRENTACTIVITY_ USERS | 96 | Reserved.
SQLNSOBJECTTYPE_DATABASE_DEFAULTS | 34 | Defaults.
SQLNSOBJECTTYPE_DATABASE_DIAGRAM | 23 | Internal use only, not exposed.
SQLNSOBJECTTYPE_DATABASE_DIAGRAMS | 22 | Database Diagrams.
SQLNSOBJECTTYPE_DATABASE_EXTENDED_SP | 31 | Specific extended stored procedure, SQLNSRootType_Server\Databases\master\Extended Stored Procedures\<xp>.
SQLNSOBJECTTYPE_DATABASE_EXTENDED_SPS | 30 | Extended stored procedure folder, SQLNSRootType_Server\Databases\master\Extended Stored Procedures.
SQLNSOBJECTTYPE_DATABASE_PUBLICATION | 14 | Specific publication in a database tree.
SQLNSOBJECTTYPE_DATABASE_PUBLICATIONS | 13 | Publications in a database tree.
SQLNSOBJECTTYPE_DATABASE_DEFAULT | 35 | Specific default.
SQLNSOBJECTTYPE_DATABASE_PUB_SUBSCRIPTION | 15 | Specific subscription to a publication in a database tree.
SQLNSOBJECTTYPE_DATABASE_PULL_SUBSCRIPTION | 17 | Specific pull subscription.
SQLNSOBJECTTYPE_DATABASE_PULL_SUBSCRIPTIONS | 16 | Pull subscriptions.
SQLNSOBJECTTYPE_DATABASE_ROLE | 21 | Specific database role.
SQLNSOBJECTTYPE_DATABASE_ROLES | 20 | Database Roles.
SQLNSOBJECTTYPE_DATABASE_RULE | 33 | Specific rule.
SQLNSOBJECTTYPE_DATABASE_RULES | 32 | Rules.
SQLNSOBJECTTYPE_DATABASE_SP | 29 | Specific stored procedure.
SQLNSOBJECTTYPE_DATABASE_SPS | 28 | Stored Procedures.
SQLNSOBJECTTYPE_DATABASE_TABLE | 25 | Specific table.
SQLNSOBJECTTYPE_DATABASE_TABLES | 24 | Tables.
SQLNSOBJECTTYPE_DATABASE_UDDT | 37 | Specific user-defined data type.
SQLNSOBJECTTYPE_DATABASE_UDDTS | 36 | User Defined Data Types.
SQLNSOBJECTTYPE_DATABASE_UDF | 102 | Specific user-defined function.
SQLNSOBJECTTYPE_DATABASE_UDFS | 101 | User-defined Functions folder.
SQLNSOBJECTTYPE_DATABASE_USER | 19 | Specific database user.
SQLNSOBJECTTYPE_DATABASE_USERS | 18 | Database Users.
SQLNSOBJECTTYPE_DATABASE_VIEW | 27 | Specific view, SQLNSRootType_Server\Databases\pubs\Views\titleview.
SQLNSOBJECTTYPE_DATABASE_VIEWS | 26 | SQL Server Views, SQLNSRootType_Server\Databases\pubs\Views.
SQLNSOBJECTTYPE_DATABASES | 4 | Databases, SQLNSRootType_Server\Databases.
SQLNSOBJECTTYPE_DB_MAINT_PLAN | 92 | Specific database maintenance plan.
SQLNSOBJECTTYPE_DB_MAINT_PLANS | 91 | Database Maintenance Plans.
SQLNSOBJECTTYPE_DTC | 40 | Distributed Transaction Coordinator.
SQLNSOBJECTTYPE_DTS_LOCALPKGS | 82 | DTS packages saved to Microsoft® SQL Server™ 2000.
SQLNSOBJECTTYPE_DTS_METADATA | 86 | DTS package meta data folder.
SQLNSOBJECTTYPE_DTS_REPOSPKGS | 83 | DTS packages saved to repository.
SQLNSOBJECTTYPE_DTSCATEGORIES | 85 | Reserved.
SQLNSOBJECTTYPE_DTSCATEGORY | 85 | Reserved.
SQLNSOBJECTTYPE_DTSCONNECTION | 90 | Reserved.
SQLNSOBJECTTYPE_DTSCONNECTIONS | 88 | Reserved.
SQLNSOBJECTTYPE_DTSPKG | 86 | Specific DTS package.
SQLNSOBJECTTYPE_DTSPKGS | 83 | DTS Packages.
SQLNSOBJECTTYPE_DTSSTEP | 89 | Reserved.
SQLNSOBJECTTYPE_DTSSTEPS | 87 | Reserved.
SQLNSOBJECTTYPE_EMPTY | 1 | Generic object type.
SQLNSOBJECTTYPE_ERRORLOG | 45 | Specific error log, SQLNSRootType_Server\Management\SQL Server Logs\Current – Date.
SQLNSOBJECTTYPE_ERRORLOGENTRY | 46 | Error log entry, SQLNSRootType_Server\Management\SQL Server Logs\Current – Date and time.
SQLNSOBJECTTYPE_ERRORLOGS | 44 | Error log folder, SQLNSRootType_Server\Management\SQL Server Logs.
SQLNSOBJECTTYPE_HETEROGENEOUS_PUB_SUBSCRIPTION | 119 | Subscription to a heterogeneous publication.
SQLNSOBJECTTYPE_HETEROGENEOUS_PUBLICATION | 118 | Specific heterogeneous publication.
SQLNSOBJECTTYPE_HETEROGENEOUS_PUBLICATIONS_FOLDER | 117 | Heterogeneous Publications folder.
SQLNSOBJECTTYPE_HETEROGENEOUS_VENDOR_FOLDER | 120 | Heterogeneous Vendors folder.
SQLNSOBJECTTYPE_INDEXSERVER | 41 | Index server catalog.
SQLNSOBJECTTYPE_INDEXSERVER_CATALOGS | 42 | Index server catalog folder.
SQLNSOBJECTTYPE_INDEXSERVER_CATOLOG | 43 | Specific index server catalog.
SQLNSOBJECTTYPE_JOBSERVER | 38 | SQL Server Agent.
SQLNSOBJECTTYPE_LINKEDSERVER | 61 | Specific linked server, SQLNSRootType_Server\Security\Linked Servers\NWIND.
SQLNSOBJECTTYPE_LINKEDSERVER_TABLE | 62 | Linked server table, SQLNSRootType_Server\Security\Linked Servers\NWIND\Tables\Categories.
SQLNSOBJECTTYPE_LINKEDSERVER_TABLES | 63 | Linked server table name, SQLNSRootType_Server\Security\Linked Servers\NWIND\Tables.
SQLNSOBJECTTYPE_LINKEDSERVERS | 55 | Linked server folder, SQLNSRootType_Server\Security\Linked Servers.
SQLNSOBJECTTYPE_LINKEDSERVER_VIEW | 122 | Specific linked server view
SQLNSOBJECTTYPE_LINKEDSERVER_VIEWS | 121 | Linked server views folder.
SQLNSOBJECTTYPE_LOCAL_JOB | 52 | Specific local job, SQLNSRootType_Server\Management\SQL Server Agent\Jobs\test.
SQLNSOBJECTTYPE_LOCAL_JOBS | 50 | Local jobs, SQLNSRootType_Server\Management\SQL Server Agent\Jobs.
SQLNSOBJECTTYPE_LOGIN | 10 | Specific user login.
SQLNSOBJECTTYPE_LOGINS | 9 | Logins.
SQLNSOBJECTTYPE_LOGSHIPPING_MONITOR | 109 | Specific Log Shipping monitor.
SQLNSOBJECTTYPE_LOGSHIPPING_MONITORS | 108 | Log Shipping monitor folder.
SQLNSOBJECTTYPE_MANAGEMENT | 6 | SQLNSRootType_Server\Management.
SQLNSOBJECTTYPE_MSX_JOBS | 49 | Reserved.
SQLNSOBJECTTYPE_MULTI_JOB | 53 | Jobs.
SQLNSOBJECTTYPE_MULTI_JOBS | 51 | Operators.
SQLNSOBJECTTYPE_OPERATOR | 59 | Server Roles.
SQLNSOBJECTTYPE_OPERATORS | 48 | Specific SQL Server log.
SQLNSOBJECTTYPE_PROFILER | 103 | SQL Server Performance Analysis Traces in the Management folder.
SQLNSOBJECTTYPE_PROFILER_TRACE | 104 | Reserved.
SQLNSOBJECTTYPE_PUBLICATIONS_FOLDER | 111 | Publications folder in the Replication folder.
SQLNSOBJECTTYPE_REMOTESERVER | 60 | Specific server role.
SQLNSOBJECTTYPE_REMOTESERVERS | 54 | SQLNSRootType_Server\Security\Remote Servers.
SQLNSOBJECTTYPE_REPLICATION | 64 | Replication folder.
SQLNSOBJECTTYPE_REPLICATION_AGENTS | 67 | Replication agents folder.
SQLNSOBJECTTYPE_REPLICATION_ALERTS | 69 | Replication alerts folder.
SQLNSOBJECTTYPE_REPLICATION_DISTRIBUTION_AGENT | 78 | Specific replication Distribution Agent.
SQLNSOBJECTTYPE_REPLICATION_DISTRIBUTION_AGENTS | 74 | Replication Distribution Agents folder.
SQLNSOBJECTTYPE_REPLICATION_LOGREADER_AGENT | 77 | Specific replication Log Reader Agent.
SQLNSOBJECTTYPE_REPLICATION_LOGREADER_AGENTS | 73 | Replication Log Reader Agents folder.
SQLNSOBJECTTYPE_REPLICATION_MERGE_AGENT | 79 | Specific replication Merge Agent.
SQLNSOBJECTTYPE_REPLICATION_MERGE_AGENTS | 75 | Replication Merge Agents folder.
SQLNSOBJECTTYPE_REPLICATION_PUBLICATION | 71 | Specific replication publication.
SQLNSOBJECTTYPE_REPLICATION_PUBLISHER | 66 | Specific replication Publisher.
SQLNSOBJECTTYPE_REPLICATION_PUBLISHERS | 65 | Replication Publishers folder.
SQLNSOBJECTTYPE_REPLICATION_REPORT | 80 | Reserved.
SQLNSOBJECTTYPE_REPLICATION_REPORTS | 68 | Reserved.
SQLNSOBJECTTYPE_REPLICATION_SNAPSHOT_AGENT | 76 | Specific replication Snapshot Agent.
SQLNSOBJECTTYPE_REPLICATION_SNAPSHOT_AGENTS | 72 | Replication Snapshot Agents folder.
SQLNSOBJECTTYPE_REPLICATION_SUBSCRIPTION | 70 | Specific replication subscription.
SQLNSOBJECTTYPE_REPLICATION_FOLDER | 110 | Replication folder.
SQLNSOBJECTTYPE_REPLICATION_FOLDER_PUB_SUBSCRIPTION | 114 | Specific subscription to a publication in the Publications folder.
SQLNSOBJECTTYPE_REPLICATION_FOLDER_PUBLICATION | 113 | Specific publication in the Publications folder.
SQLNSOBJECTTYPE_REPLICATION_FOLDER_PUSH_SUBSCRIPTION | 116 | Specific push subscription in the Subscriptions folder.
SQLNSOBJECTTYPE_REPLICATION_FOLDER_SUBSCRIPTION | 115 | Specific pull subscription in the Subscriptions folder.
SQLNSOBJECTTYPE_REPLICATION_MONITOR_GROUP | 105 | Replication monitor group folder.
SQLNSOBJECTTYPE_REPLICATION_QUEUEREADER_AGENT | 107 | Specific replication Queue Reader Agent.
SQLNSOBJECTTYPE_REPLICATION_QUEUEREADER_AGENTS | 106 | Replication Queue Reader Agents Folder.
SQLNSOBJECTTYPE_ROOT | 0 | Generic root node.
SQLNSOBJECTTYPE_SECURITY | 7 | Security folder SQLNSRootType_Server\Security.
SQLNSOBJECTTYPE_SERVER | 3 | Server.
SQLNSOBJECTTYPE_SERVER_GROUP | 2 | Server group.
SQLNSOBJECTTYPE_SERVERROLE | 57 | Specific remote server.
SQLNSOBJECTTYPE_SERVERROLES | 56 | Remote server folder, SQLNSRootType_Server\Security\Server Roles.
SQLNSOBJECTTYPE_SERVICES | 8 | Services folder, SQLNSRootType_Server\Support Services.
SQLNSOBJECTTYPE_SQLMAIL | 39 | SQL Mail.
SQLNSOBJECTTYPE_SUBSCRIPTIONS_FOLDER | 112 | Subscriptions folder in the Replication folder.
SQLNSOBJECTTYPE_WEBASSISTANTJOB | 94 | Specific Web Assistant job.
SQLNSOBJECTTYPE_WEBASSISTANTJOBS | 93 | Web Assistant Jobs.


SQLNSRootType

SQLNSRootType constants specify the type of object to set as root.

Constant | Value | Description
SQLNSRootType_Database | 3 | Databases (preferred setting).
SQLNSRootType_DefaultRoot | 0 | Console tree.
SQLNSRootType_Server | 2 | Server name (preferred setting).
SQLNSRootType_ServerGroup | 1 | Server group node.


SQL-NS Samples

Microsoft® SQL Server™ 2000 includes the following SQL-NS to introduce you to using SQL Namespace (SQL-NS):

Sample | Description
SQL-NS Sample Program Using Visual Basic | This sample Microsoft Visual Basic® application demonstrates how to use SQL-NS to display the Properties dialog box for the pubs database.
SQL-NS Sample Program Using C++ | This sample Microsoft Visual C++® application demonstrates how to use SQL-NS to display the Properties dialog box for the pubs database.
SQL Namespace Sample Browser | This sample Microsoft Visual Basic application demonstrates how to view the SQL Namespace object hierarchy, and view and execute the commands available for each object.
SQL Namespace Dump Tree | This sample console application demonstrates how to display the objects in the SQL Namespace tree for the default instance of Microsoft SQL Server™ 2000 running on the local computer.

To install the samples during SQL Server installation
  1. On the Setup Type page, select Custom.

  2. On the Select Components page, under Components, select Code Samples.

Samples are installed as a self-extracting file. To extract the samples, double-click Unzip_sqlns.exe, located at
C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Sqlns.

Prerequisites

C++ samples require Microsoft Visual C++ version 6.0. Visual Basic samples require Microsoft Visual Basic version 6.0.

See Also

Samples


SQL-NS Sample Program Using Visual Basic

This sample Microsoft® Visual Basic® application demonstrates how to use SQL-NS to display the Properties dialog box for the pubs database.

Default Location

C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Sqlns\Vb\Dbprop

Running the Sample

Open the Microsoft Visual Basic project file, Dbprop.vbp, and then start the project.

See Also

SQL-NS Samples


SQL-NS Sample Program Using C++

This sample Microsoft® Visual C++® application demonstrates how to use SQL-NS to display the Properties dialog box for the pubs database.

Default Location

C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Sqlns\Cpp\Dbprop

Running the Sample

Open the Microsoft Visual C++ workspace file, Dbprop.dsw, and then start the project.

See Also

SQL-NS Samples


SQL Namespace Sample Browser

This sample Microsoft® Visual Basic® application demonstrates how to view the SQL Namespace object hierarchy, and view and execute the commands available for each object. The browser also displays the SQLNSObjectType and SQLNSCommandID for your selections.

Default Location

C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Sqlns\Vb\Browse

Running the Sample

Open the Microsoft Visual Basic project file, Browse.vbp, and then start the project.

Remarks

This table describes the function of each item on the user interface.

Use this | To do this
Root Object | Select the highest level object to be shown in the browser.
Server | Enter the name of the server to connect to when the Root Object is a server or database.
Server Group | Enter the name of the server group to browse when the Root Object is a server group.
User | Enter the user name to connect to a server.
Password | Enter the password to connect to a server.
Integrated Security | Connect to a server using the integrated security.
Database | Enter the name of the database to browse when the Root Object is a database.
Connect | Begin browsing at the specified Root Object and then, if necessary, log on to a server or database.
Disconnect | Disconnect from any servers or databases and stop browsing.
SQL Namespace Browser | View the SQL Namespace object hierarchy.
Commands | View and execute the commands available for the object selected in the SQL Namespace Browser.
Refresh | Refresh the SQL Namespace Browser.
Execute | Execute the command selected in the Commands list. You can also execute a command by double-clicking it in the Commands list.

See Also

SQL-NS Samples


SQL Namespace Dump Tree

This sample console application demonstrates how to display the objects in the SQL Namespace tree for the default instance of Microsoft® SQL Server™ 2000 running on the local computer.

Default Location

C:\Program Files
\Microsoft SQL Server\80\Tools\Devtools\Samples\Sqlns\Cpp\Dumptree

Running the Sample

Open the Microsoft Visual C++® workspace file, Dumptree.dsw, and then start the project.

See Also

SQL-NS Samples