Skip to content

Latest commit

 

History

History
90 lines (63 loc) · 5.34 KB

File metadata and controls

90 lines (63 loc) · 5.34 KB
title ms.custom ms.date ms.prod ms.prod_service ms.reviewer ms.technology ms.topic helpviewer_keywords ms.assetid author ms.author monikerRange
Data source objects (Native Client OLE DB provider) | Microsoft Docs
03/16/2017
sql
database-engine, sql-database, sql-data-warehouse, pdw
native-client
reference
data access [SQL Server Native Client], data source objects
SQL Server Native Client, data source objects
SQLNCLI, data source objects
SQL Server Native Client OLE DB provider, data source objects
OLE DB data source objects [SQL Server Native Client]
data source objects [OLE DB]
CLSID
c1d4ed20-ad3b-4e33-a26b-38d7517237b7
markingmyname
maghan
>=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current

SQL Server Native Client Data Source Objects (OLE DB)

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW ]

[!INCLUDEssNoVersion] Native Client uses the term data source for the set of OLE DB interfaces used to establish a link to a data store, such as [!INCLUDEssNoVersion]. Creating an instance of the data source object of the provider is the first task of a [!INCLUDEssNoVersion] Native Client consumer.

Every OLE DB provider declares a class identifier (CLSID) for itself. The CLSID for the [!INCLUDEssNoVersion] Native Client OLE DB provider is the C/C++ GUID CLSID_SQLNCLI10 (the symbol SQLNCLI_CLSID will resolve to the correct progid in the sqlncli.h file that you reference). With the CLSID, the consumer uses the OLE CoCreateInstance function to manufacture an instance of the data source object.

[!INCLUDEssNoVersion] Native Client is an in-process server. Instances of [!INCLUDEssNoVersion] Native Client OLE DB provider objects are created using the CLSCTX_INPROC_SERVER macro to indicate the executable context.

The [!INCLUDEssNoVersion] Native Client OLE DB provider data source object exposes the OLE DB initialization interfaces that allow the consumer to connect to existing [!INCLUDEssNoVersion] databases.

Every connection made through the [!INCLUDEssNoVersion] Native Client OLE DB provider sets these options automatically:

  • SET ANSI_WARNINGS ON

  • SET ANSI_NULLS ON

  • SET ANSI_PADDING ON

  • SET ANSI_NULL_DFLT_ON ON

  • SET QUOTED_IDENTIFIER ON

  • SET CONCAT_OF_NULL_YIELDS_NULL ON

This example uses the class identifier macro to create a [!INCLUDEssNoVersion] Native Client OLE DB provider data source object and get a reference to its IDBInitialize interface.

IDBInitialize*   pIDBInitialize;  
HRESULT          hr;  
  
hr = CoCreateInstance(CLSID_SQLNCLI10, NULL, CLSCTX_INPROC_SERVER,  
    IID_IDBInitialize, (void**) &pIDBInitialize);  
  
if (SUCCEEDED(hr))  
{  
    //  Perform necessary processing with the interface.  
    pIDBInitialize->Uninitialize();  
    pIDBInitialize->Release();  
}  
else  
{  
    // Display error from CoCreateInstance.  
}  

With successful creation of an instance of a [!INCLUDEssNoVersion] Native Client OLE DB provider data source object, the consumer application can continue by initializing the data source and creating sessions. OLE DB sessions present the interfaces that allow data access and manipulation.

The [!INCLUDEssNoVersion] Native Client OLE DB provider makes its first connection to a specified instance of [!INCLUDEssNoVersion] as part of a successful data source initialization. The connection is maintained as long as a reference is maintained on any data source initialization interface, or until the IDBInitialize::Uninitialize method is called.

In This Section

See Also

SQL Server Native Client (OLE DB)