Поделиться через


C++ and SQL Server

A customer asked me this morning about connecting to SQL Server from C++. Had to dig a little, but found some pretty good info and some sample code.

Building applications with SQL Native Client: https://msdn.microsoft.com/en-us/library/ms130904.aspx  From that page:

SQL Server Native Client is a stand-alone data access application programming interface (API), used for both OLE DB and ODBC, that was introduced in SQL Server 2005. SQL Server Native Client combines the SQL OLE DB provider and the SQL ODBC driver into one native dynamic-link library (DLL). It also provides new functionality above and beyond that supplied by the Windows Data Access Components (Windows DAC, formerly Microsoft Data Access Components, or MDAC). SQL Server Native Client can be used to create new applications or enhance existing applications that need to take advantage of features introduced in SQL Server 2005, such as multiple active result sets (MARS), user-defined data types (UDT), query notifications, snapshot isolation, and XML data type support.

When to use SQL Server Native Client: https://msdn.microsoft.com/en-us/library/ms130828.aspx

Using the SQL Server Native Client header and library files: https://msdn.microsoft.com/en-us/library/ms131291.aspx

ODBC How-to topics: https://msdn.microsoft.com/en-us/library/ms403288.aspx

Allocate handles and connect to SQL Server (ODBC) – includes sample code: https://msdn.microsoft.com/en-us/library/ms403303.aspx

OLE DB How-to topics: https://msdn.microsoft.com/en-us/library/ms403342.aspx

Enjoy!
-bliz