SqlServerEnum%

Lists the names of local SQL Servers, network SQL Servers, or both.

Syntax

SqlServerEnum% ( searchmode%, serverbuf$, numentries% )

where

searchmode%
Determines whether SqlServerEnum% checks for server names locally, on the network, or both.

LOCSEARCH searches for the server names listed in the WIN.INI file. LOCSEARCH has the value 1.

NETSEARCH searches for server names on the network type defined by the default Net-Library. The VBSQL Library loads the default Net-Library set by the DSQUERY entry in the WIN.INI file. If no default entry exists, the VBSQL Library loads the named pipes Net-Library. NETSEARCH has the value 2.

(LOCSEARCH NETSEARCH) searches for server names using both methods, searching first for server names listed in the WIN.INI file and then for server names on the network type defined by the default Net-Library. A server name is listed twice if it is specified in the WIN.INI file and is also available on the default network type.

serverbuf$
Is the buffer that stores the server names that SqlServerEnum% returns. You must preallocate this buffer using an appropriate Visual Basic function such as Space$. DB-Library for Visual Basic determines the length of the buffer based on what you allocated.
numentries%
Is an output parameter that returns the number of server names copied to the buffer by the current call to SqlServerEnum%.

Returns

SqlServerEnum% returns one or more of the following status codes:

Constant Value
ENUMSUCCESS% 0
MOREDATA% 1
NETNOTAVAIL% 2
OUTOFMEMORY% 4
NOTSUPPORTED% 8

Remarks

The SqlServerEnum% function returns a list of server names to the server$ buffer in the order in which it finds them. LOCSEARCH names are listed before NETSEARCH names. Only complete server names are copied to the buffer. Each server name is separated by a null character (chr$(0)).

The end of the list is designated by two consecutive null characters. If the buffer becomes full before SqlServerEnum% has finished sending names, SqlServerEnum% returns the value MOREDATA.

Note that on named pipes networks, SqlServerEnum% returns the server names of computers on which SQL Server is installed, regardless of whether or not SQL Server is currently running.

See Also

SqlOpen%