TechNet
Export (0) Print
Expand All

SQLBrowseConnect

 

System_CAPS_ICON_warning.jpg Warning

SQL Server Native Client (SNAC) is not supported beyond SQL Server 2012. Avoid using SNAC in new development work, and plan to modify applications that currently use it. The Microsoft ODBC Driver for SQL Server provides native connectivity from Windows to Microsoft SQL Server and Microsoft Azure SQL Database.

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.

KeywordList returned?Optional?Description
DSNN/ANoName of the data source returned by SQLDataSources. The DSN keyword cannot be used if the DRIVER keyword is used.
DRIVERN/ANoMicrosoft® SQL Server Native Client ODBC driver name is {SQL Server Native Client 11}. The DRIVER keyword cannot be used if the DSN keyword is used.
KeywordList returned?Optional?Description
SERVERYesNoName of the server on the network on which the data source resides. The term "(local)" can be entered as the server, in which case a local copy of SQL Server can be used, even when this is a non-networked version.
UIDNoYesUser login ID.
PWDNoYes (depends on the user)User-specified password.
APPNoYesName of the application calling SQLBrowseConnect.
WSIDNoYesWorkstation ID. Typically, this is the network name of the computer on which the application runs.
KeywordList returned?Optional?Description
DATABASEYesYesName of the SQL Server database.
LANGUAGEYesYesNational 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.

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

AttributeDescription
SQL_COPT_SS_BROWSE_CONNECTIf it is set to SQL_MORE_INFO_YES, SQLBrowseConnect returns an extended string of server properties.

The following is an example of an extended string returned by SQLBrowseConnect:

 

 ServerName\InstanceName;Clustered:No;Version:8.00.131

 

In this string, semi-colons separate various pieces of information about the server. Use commas to separate different server instances.
SQL_COPT_SS_BROWSE_SERVERIf 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.

 

Note that due to network issues, SQLBrowseConnect might not receive a timely response from all servers. Therefore, the list of servers returned can vary for each request.
SQL_COPT_SS_BROWSE_CACHE_DATAWhen the SQL_COPT_SS_BROWSE_CACHE_DATA attribute is set to SQL_CACHE_DATA_YES, you can fetch data in chunks when the buffer length is not large enough to hold the result. This length is specified in the BufferLength argument to SQLBrowseConnect.

SQL_NEED_DATA is returned when more data is available. SQL_SUCCESS is returned when there is no more data to retrieve.

The default is SQL_CACHE_DATA_NO.

For more information on using SQLBrowseConnect to connect to an Always On Availability Groups cluster, see SQL Server Native Client Support for High Availability, Disaster Recovery.

When a connection is opened, SQL Server Native Client sets SQL_COPT_SS_MUTUALLY_AUTHENTICATED and SQL_COPT_SS_INTEGRATED_AUTHENTICATION_METHOD to the authentication method used to open the connection.

For more information about SPNs, see Service Principal Names (SPNs) in Client Connections (ODBC).

Updated content
Documented SQL_COPT_SS_BROWSE_CACHE_DATA.

SQLBrowseConnect Function
ODBC API Implementation Details

Community Additions

ADD
Show:
© 2016 Microsoft