Search code examples
c++sql-serverodbcoledb

SQL Server 2012 via native C++ (no ATL) preferred access method from Windows


I have a native C++ application that runs under Windows 64, it doesn't use ATL (and will not). I want to be able to connect from my application to SQL Server 2012 over the network.

I have the following requirements:

  • Performance is the key

  • The C++ will only insert records (say by calling Stored Procs), nothing else (no selects, deletes or updates).

  • Record insertions should be non-blocking (async).

I narrowed my choices down to OLE DB and ODBC as they satisfy the criteria above. However, it seems that the Internet have loads of contradicting advice of what to use. Examples:

I am really confused and would like to take more opinions on the best technology to access SQL Server with my criteria.


Solution

  • Both OleDB and ODBC use the SQLNCLI. See the Component Names and Properties by Version table, observer how Sqlncli.dll/Sqlncli10.dll/Sqlncli11.dll is the driver for both ODBC and OleDB.

    If you look at Data Access Technologies Road Map you'll see that both ODBC and OleDB are current and supported. What is deprecated is SQLOLEDB and SQLODBC, which are the old MDAC SQL Server drives for OleDB and ODBC (ie. sqlsrv32.dll and Sqloledb.dll). For both of them there are upgrade paths and recomendations, see Updating an Application to SQL Server Native Client from MDAC.

    So the conclusion is that you can safely continue to use both ODBC and OleDB, just make sure you use the modern SLNCLI based drivers and not the old, deprecated, MDAC drivers.

    The main risk in using deprecated drivers is lack of support for new data types (eg. geography, hierachy, datetime2 etc etc).