locked
Database Access from a C++ App RRS feed

  • Question

  • Hello,

    I have a C++ app written in Visual Studio 2015, from which I'd like to connect to an SQL Server 2008 database. I haven't been able to find a code example that both specifies the necessary header files and builds. Any help will be appreciated.

    Dave

    Friday, September 25, 2015 8:15 PM

Answers

  • See this on ODBC as the primary support for SQL Server with native C++:

    Microsoft is Aligning with ODBC for Native Relational Data Access - FAQ

    https://social.msdn.microsoft.com/Forums/en-US/e696d0ac-f8e2-4b19-8a08-7a357d3d780f/microsoft-is-aligning-with-odbc-for-native-relational-data-access-faq?forum=sqldataaccess

    Here's a link to a word document for those moving from OLEDB to ODBC.

    https://msdn.microsoft.com/en-us/library/hh967418.aspx?f=255&MSPPError=-2147217396

    Looks like COM is the best way to access ODBC and that's pretty easy in MS C++.

    • Proposed as answer by Shu 2017 Tuesday, September 29, 2015 2:02 AM
    • Marked as answer by Dave DeBenedetto Tuesday, September 29, 2015 12:56 PM
    Saturday, September 26, 2015 4:43 AM
  • I have a C++ app written in Visual Studio 2015, from which I'd like to connect to an SQL Server 2008 database. I haven't been able to find a code example that both specifies the necessary header files and builds. Any help will be appreciated.

    For ODBC, you could find some samples on MSDN, for example this:

    ODBC database sample

    And for more information about ODBC development, please check this:

    ODBC Programmer's Reference


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Proposed as answer by Shu 2017 Tuesday, September 29, 2015 2:02 AM
    • Edited by Shu 2017 Tuesday, September 29, 2015 2:03 AM
    • Marked as answer by Dave DeBenedetto Tuesday, September 29, 2015 12:56 PM
    Tuesday, September 29, 2015 2:02 AM

All replies

  • See this on ODBC as the primary support for SQL Server with native C++:

    Microsoft is Aligning with ODBC for Native Relational Data Access - FAQ

    https://social.msdn.microsoft.com/Forums/en-US/e696d0ac-f8e2-4b19-8a08-7a357d3d780f/microsoft-is-aligning-with-odbc-for-native-relational-data-access-faq?forum=sqldataaccess

    Here's a link to a word document for those moving from OLEDB to ODBC.

    https://msdn.microsoft.com/en-us/library/hh967418.aspx?f=255&MSPPError=-2147217396

    Looks like COM is the best way to access ODBC and that's pretty easy in MS C++.

    • Proposed as answer by Shu 2017 Tuesday, September 29, 2015 2:02 AM
    • Marked as answer by Dave DeBenedetto Tuesday, September 29, 2015 12:56 PM
    Saturday, September 26, 2015 4:43 AM
  • I have a C++ app written in Visual Studio 2015, from which I'd like to connect to an SQL Server 2008 database. I haven't been able to find a code example that both specifies the necessary header files and builds. Any help will be appreciated.

    For ODBC, you could find some samples on MSDN, for example this:

    ODBC database sample

    And for more information about ODBC development, please check this:

    ODBC Programmer's Reference


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Proposed as answer by Shu 2017 Tuesday, September 29, 2015 2:02 AM
    • Edited by Shu 2017 Tuesday, September 29, 2015 2:03 AM
    • Marked as answer by Dave DeBenedetto Tuesday, September 29, 2015 12:56 PM
    Tuesday, September 29, 2015 2:02 AM
  • Thank you, this is exactly what I was looking for :)

    Dave

    Tuesday, September 29, 2015 12:57 PM
  • Thank you, this is exactly what I was looking for :)

    Dave

    Tuesday, September 29, 2015 12:58 PM