Skip to content

EnumerateServersLocal - cMSSQLHandler

Enumerates Microsoft SQL Servers currently available on the local Windows machine

Type: Function
Return Data Type: Integer

Syntax

Function EnumerateServersLocal Returns Integer

Call Example

Get EnumerateServersLocal to IntegerVariable

Description

This method enumerates Microsoft SQL Servers currently available on the local Windows machine. The number of servers found is returned and the server names can be retrieved from the array (sMSSQLHandler's superclass is Array) with the value message.

Note that this function sometimes takes a long time to complete.

Sample

Object oServerNameComboForm is a ComboForm
    Set Size to 13 415
    Set Location to 5 60
    Set Label to "Server Name:"
    Set Label_Justification_Mode to JMode_Right
    Set Label_Col_Offset to 2

    Procedure OnChange
        Forward Send OnChange

        Send ToggleChangesPresent True
    End_Procedure

    Procedure ScanServers
        Handle hoSQLHandler
        Integer iNumServers iServer
        String sServer

        Forward Send Combo_Fill_List

        Get Create (RefClass (cMSSQLhandler)) to hoSQLHandler                
        If (hoSQLHandler <> 0) Begin
            Get EnumerateServersLocal of hoSQLHandler to iNumServers
            Decrement iNumServers
            For iServer from 0 to iNumServers
                Get Value of hoSQLHandler iServer to sServer
                Send Combo_Add_Item sServer
            Loop
            Send Destroy of hoSQLHandler
        End
    End_Procedure

    Procedure OnDropDown
        Send Combo_Delete_Data
        Send ScanServers
    End_Procedure
End_Object