Working with a database in C++

Posted on 2006-06-05
Last Modified: 2008-02-01
I am using Visual C++ (inside Visual Studio 2005) and want to be able to connect to a SQL Server 2005 database.  I would prefer having a Win32 console project, versus a .NET one for performance reasons.  I will be executing scalar statements [i.e. SELECT COUNT(*) FROM Runs    or    INSERT INTO Runs (ExperimentID, TheName) VALUES (3, 'Test')]

How do I do this?  Is there a built-in library?  Or is there a 3rd party one I can use?
Question by:stev0931
    LVL 48

    Accepted Solution

    ADO is most popular kit for database access:

    You can read more about ADO here:

    Notice that you don't have any advantages using unmanaged code for database access. For database application I would prefer C# - just for information.
    LVL 48

    Expert Comment

    This site helps for building connection strings:

    Author Comment

    I am getting the following error:

    Error      1      fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory      p:\visual studio projects\small-productivity\evolprocessor\evolprocessor2\stdafx.h      12      

    When I follow the instructions in the link...

    By typing the following lines in your stdafx.h you simply can do the same too.

            #import "msado15.dll" \
          no_namespace \
            rename( "EOF", "adoEOF" )


    Author Comment

    I just figured out where msado15.dll is and have fixed the problem above.  I don't have the ADO working though, since I can't seem to find the equiv. of ExecuteScalar from ADO.NET  ExecuteScalar returns a single object (like a number).  Is there anything like this in ADO?


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now