CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2014
    Posts
    13

    Question c++ wrapper for sql server?

    hello guys

    i need a c++ sql server wrapper that can connect to sql server using odbc.
    i find this one but i cant able to use it in visual studio 2015 community
    so if anyone of you know the best c++ odbc wrapper please suggest me.
    1 nanodbc [i try to use this but visual studio give me so many error coz it use c++ 11 standard i guess , alos it didnt work in code block (gcc compiler)]

    2 TinyODBC C++ this one also not working

    if someone plz try to compile the nanodbc in visual studio and tell me that you able to do that or not ?

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: c++ wrapper for sql server?

    nanodbc.cpp/nanodbc.h compiles OK for me with MS VS 2015 Community with just a couple of warnings.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Aug 2014
    Posts
    13

    Re: c++ wrapper for sql server?

    Quote Originally Posted by 2kaud View Post
    nanodbc.cpp/nanodbc.h compiles OK for me with MS VS 2015 Community with just a couple of warnings.
    do you have sql server or mysql use the odbc and try to connect the database using nanodbc and tell me if it works in visual studio 2015

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: c++ wrapper for sql server?

    If you're using Visual Studio, why not use the CRecordset class?

  5. #5
    Join Date
    Aug 2014
    Posts
    13

    Re: c++ wrapper for sql server?

    Quote Originally Posted by GCDEF View Post
    If you're using Visual Studio, why not use the CRecordset class?
    can you give me the link of the tutorial how to use the CRecordset class ?

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: c++ wrapper for sql server?

    https://msdn.microsoft.com/en-us/library/92bcy0kw.aspx

    there are also examples documented with some of the class functions eg https://msdn.microsoft.com/en-us/library/1hkkwdf0.aspx

    If you search MSDN there are other examples of its use.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: c++ wrapper for sql server?

    Quote Originally Posted by tjnapster555 View Post
    can you give me the link of the tutorial how to use the CRecordset class ?
    I'm pretty sure Google can point you in the right direction.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: c++ wrapper for sql server?

    Another option for Visual Studio C++ is to use the ATL Database consumer classes. They are not well known, but are lighter weight and easier to use than the MFC database classes, imo.

  9. #9
    Join Date
    Aug 2014
    Posts
    13

    Re: c++ wrapper for sql server?

    Quote Originally Posted by Arjay View Post
    Another option for Visual Studio C++ is to use the ATL Database consumer classes. They are not well known, but are lighter weight and easier to use than the MFC database classes, imo.

    can you give me the link of tutorial other than Microsoft website which i never understand

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: c++ wrapper for sql server?

    Quote Originally Posted by Arjay View Post
    Another option for Visual Studio C++ is to use the ATL Database consumer classes. They are not well known, but are lighter weight and easier to use than the MFC database classes, imo.
    I always was fine with plain ADO. Never even thought about third party classes. However, in one of commercial projects I had to use something really lightweight and license-safe, so I ended up with a minimalistic ODBC wrapper made all myself. It din't take me much time to craft one, and supporting it for years never caused any trouble as it was nothing more than just ODBC API with C++ as little as possible.

    Quote Originally Posted by tjnapster555 View Post
    can you give me the link of tutorial other than Microsoft website which i never understand
    Sorry, all the links that I have are from MSDN.
    Best regards,
    Igor

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: c++ wrapper for sql server?

    It's too bad that no one uses the ATL consumer db classes - imo, they are much easier to use than the MFC classes. Also, if the db schema changes, there only one file to update.

    I don't have anything more recent but the following link is how the use the ATL Consumer db classes to connect to an Access db.

    http://forums.codeguru.com/showthrea...ables-database

    Connecting to sql is a simple matter of point the wizard to a sql data source instead of access.

    This link has example source code and you should be able to import the sln into a more recent version of Visual Studio. Probably some some of the wizard steps descibed in the text have changed as well. Still, it should be enough to get you going.
    Last edited by Arjay; November 5th, 2015 at 08:40 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured