SQLBrowseConnect

ODBC and SQL Server

ODBC and SQL Server

SQLBrowseConnect

SQLBrowseConnect uses keywords that can be categorized into three levels of connection information. For each keyword, the following table indicates whether a list of valid values is returned and whether the keyword is optional.

Level 1
Keyword List returned? Optional? Description
DSN N/A No Name of the data source returned by SQLDataSources. The DSN keyword cannot be used if the DRIVER keyword is used.
DRIVER N/A No Microsoft® SQL Server™ ODBC driver name is {SQL Server} or SQL Server (braces are required when using driver version 2.65 or earlier). The DRIVER keyword cannot be used if the DSN keyword is used.
Level 2
Keyword List returned? Optional? Description
SERVER Yes No Name of the server on the network on which the data source resides. When running on Microsoft Windows NT® 4.0, "(local)" can be entered as the server, in which case a local copy of SQL Server can be used, even when this is a nonnetworked version.
UID No Yes User login ID.
PWD No Yes (depends on the user) User-specified password.
APP No Yes Name of the application calling SQLBrowseConnect.
WSID No Yes Workstation ID. Typically, this is the network name of the computer on which the application runs.

Level 3
Keyword List returned? Optional? Description
DATABASE Yes Yes Name of the SQL Server database.
LANGUAGE Yes Yes National language used by SQL Server.

SQLBrowseConnect ignores the values of the DATABASE and LANGUAGE keywords stored in the ODBC data source definitions. If the database or language specified in the connection string passed to SQLBrowseConnect is invalid, SQLBrowseConnect returns SQL_NEED_DATA and the level 3 connection attributes.

SQLBrowseConnect does not verify user access to all the databases listed with the DATABASE keyword when connected to SQL Server version 6.5 or earlier servers. If the user does not have access to the chosen database, SQLBrowseConnect returns SQL_NEED_DATA and the level 3 connection attributes.

The following attributes, set by calling SQLSetConnectAttr, determine the result set returned by SQLBrowseConnect.

SQL_COPT_SS_BROWSE_CONNECT: If it is set to SQL_MORE_INFO_NO, in SQL Server version 6.5 and later, SQLBrowseConnect returns a list of servers. If it is set to SQL_MORE_INFO_YES, in SQL Server version 6.5 and 7.0, SQLBrowseConnect returns a list of servers. In SQL Server 2000, SQLBrowseConnect returns an extended string of server properties.

This is an example of an extended string returned by SQLBrowseConnect in SQL Server 2000:

ServerName\InstanceName;Clustered:No;Version:8.00.131

In this string, semi-colons separate various parts of information about the server, and commas separate different server instances.

SQL_COPT_SS_BROWSE_SERVER: If a server name is specified, SQLBrowseConnect will return information for the server specified. If SQL_COPT_SS_BROWSE_SERVER is set to NULL, SQLBrowseConnect returns information for all servers in the domain.