Skip to content

Latest commit

 

History

History
102 lines (74 loc) · 8.25 KB

using-the-sql-server-native-client-header-and-library-files.md

File metadata and controls

102 lines (74 loc) · 8.25 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Header and Library Files
Learn how to use the SQL Server Native Client header and library files to develop an application. Copy required files to your development environment.
markingmyname
maghan
03/14/2017
sql
native-client
reference
header files [SQL Server Native Client]
SQLNCLI, header files
OLE DB, header files
library files [SQL Server Native Client]
SQL Server Native Client, header files
data access [SQL Server Native Client], header files
SQL Server Native Client ODBC driver,header files
data access [SQL Server Native Client], library files
SQL Server Native Client, library files
ODBC applications, header files
SQLNCLI, library files

Using the SQL Server Native Client Header and Library Files

[!INCLUDE SQL Server]

Important

[!INCLUDEsnac-removed-oledb-and-odbc]

The [!INCLUDEssNoVersion] Native Client header and library files are installed with [!INCLUDEssNoVersion]. When developing an application, it is important to copy and install all of the required files for development to your development environment. For more information about installing and redistributing [!INCLUDEssNoVersion] Native Client, see Installing SQL Server Native Client.

The [!INCLUDEssNoVersion] Native Client header and library files are installed in the following location:

%PROGRAM FILES%\Microsoft SQL Server\110\SDK

The [!INCLUDEssNoVersion] Native Client header file (sqlncli.h) can be used to add [!INCLUDEssNoVersion] Native Client data access functionality to your custom applications. The [!INCLUDEssNoVersion] Native Client header file contains all of the definitions, attributes, properties, and interfaces needed to take advantage of the new features introduced in [!INCLUDEssVersion2005].

In addition to the [!INCLUDEssNoVersion] Native Client header file, there is also a sqlncli11.lib library file which is the export library for [!INCLUDEssNoVersion] Bulk Copy Program (BCP) functionality for ODBC.

The [!INCLUDEssNoVersion] Native Client header file is backwards compatible with both the sqloledb.h and odbcss.h header files used with Microsoft Data Access Components (MDAC), but does not contain CLSIDs for SQLOLEDB (the OLE DB provider for [!INCLUDEssNoVersion] included with MDAC) or symbols for XML functionality (which is not supported by [!INCLUDEssNoVersion] Native Client).

ODBC applications cannot reference the [!INCLUDEssNoVersion] Native Client header (sqlncli.h) and odbcss.h in the same program. Even if you are not using any of the features introduced in [!INCLUDEssVersion2005], the [!INCLUDEssNoVersion] Native Client header file will work in place of the older odbcss.h.

OLE DB applications which use the [!INCLUDEssNoVersion] Native Client OLE DB provider only need to reference sqlncli.h. If an application uses both MDAC (SQLOLEDB) and the [!INCLUDEssNoVersion] Native Client OLE DB provider, it can reference both sqloledb.h and sqlncli.h, but the reference to sqloledb.h must come first.

Using the SQL Server Native Client Header File

To use the [!INCLUDEssNoVersion] Native Client header file, you must use an include statement within your C/C++ programming code. The following sections describe how to do this for both OLE DB and ODBC applications.

Note

The [!INCLUDEssNoVersion] Native Client header and library files can only be compiled using Visual Studio C++ 2002 or later.

OLE DB

To use the [!INCLUDEssNoVersion] Native Client header file in an OLE DB application, using the following lines of programming code:

#define _SQLNCLI_OLEDB_  
include "sqlncli.h";  

Note

The first line of code shown above should be omitted if both the OLE DB and ODBC APIs are used by the application. In addition, if the application has an include statement for sqloledb.h, the include statement for sqlncli.h must come after it.

When creating a connection to a data source through [!INCLUDEssNoVersion] Native Client, use "SQLNCLI11" as the provider name string.

ODBC

To use the [!INCLUDEssNoVersion] Native Client header file in an ODBC application, using the following lines of programming code:

#define _SQLNCLI_ODBC_  
include "sqlncli.h";  

Note

The first line of code shown above should be omitted if both OLE DB and ODBC APIs are used by the application. In addition, if the application has an #include statement for odbcss.h, it should be removed.

When creating a connection to a data source through [!INCLUDEssNoVersion] Native Client, use "SQL Server Native Client 11.0" as the driver name string.

Component Names and Properties by Version

Property SQL Server Native Client

SQL Server 2005
SQL Server Native Client 10.0

SQL Server 2008
SQL Server Native Client 11.0

[!INCLUDE sssql11-md]
MDAC
ODBC driver name SQL Native Client SQL Server Native Client 10.0 SQL Server Native Client 11.0 SQL Server
ODBC header file name Sqlncli.h Sqlncli.h Sqlncli.h Odbcss.h
ODBC driver DLL Sqlncli.dll Sqlncl10.dll Sqlncl11.dll sqlsrv32.dll
ODBC lib file for BCP APIs Sqlncli.lib Sqlncli10.lib Sqlncli11.lib Odbcbcp.lib
ODBC DLL for BCP APIs Sqlncli.dll Sqlncli10.dll Sqlncli11.dll Odbcbcp.dll
OLE DB PROGID SQLNCLI SQLNCLI10 SQLNCLI11 SQLOLEDB
OLE DB header file name Sqlncli.h Sqlncli.h Sqlncli.h Sqloledb.h
OLE DB provider DLL Sqlncli.dll Sqlncli10.dll Sqlncli11.dll Sqloledb.dll

sqlncli.h supports multiple version of [!INCLUDEssNoVersion] Native Client through the SQLNCLI_VER macro. By default, SQLNCLI_VER defaults to the latest version of [!INCLUDEssNoVersion] Native Client. To build an application that uses sqlncli10.dll rather than sqlncli11.dll, set SQLNCLI_VER to 10.

Static Linking and BCP Functions

When an application uses BCP functions, it is important for the application to specify in the connection string the driver from the same version that shipped with the header file and library used to compile the application.

For example, if you compile an application using [!INCLUDEssNoVersion] Native Client, and the associated library file (sqlncli11.lib) and header file (sqlncli.h) from \Program Files\Microsoft SQL Server\110\SDK, make sure to specify (using ODBC as an example) "DRIVER={SQL Server Native Client 11.0}" in the connection string.

For more information, see Performing Performing Bulk Copy Operations.

See Also

Building Applications with SQL Server Native Client