[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

Working with a database in C++

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?
0
stev0931
Asked:
stev0931
  • 2
  • 2
1 Solution
 
AlexFMCommented:
ADO is most popular kit for database access:
http://www.codeproject.com/database/simpleado.asp

You can read more about ADO here:
http://www.codeproject.com/database/#ADO

Notice that you don't have any advantages using unmanaged code for database access. For database application I would prefer C# - just for information.
0
 
AlexFMCommented:
This site helps for building connection strings:
http://www.connectionstrings.com/
0
 
stev0931Author Commented:
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" )

0
 
stev0931Author Commented:
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?

Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now