Access database from within C++

Posted on 2003-03-06
Medium Priority
Last Modified: 2010-04-01
I am doing a school project. The project has to do several things such as customer management, project management, employee management, billing, etc. Together with my partner I decided we want to use an MS Access database for this. We can use any database engine we like, such as MS SQL, MySQL, etc. But because the project isn't that complicated and doesn't require a high performance database we decided to go with Access. However, I have no clue on how I can access the database WITHOUT using ODBC. The project is written using Microsoft Visual C++ 6 using pure Win32(NO MFC).

Anyone has an idea what we should use?

Question by:Toolmaker
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 8079489
Any reason why you can't use ODBC or ADO?

If you can't use ODBC or ADO, you should use SQL, it is simple enough:

Get connection to the database then send in a string of something like:

"SELECT foo, bar, baz FROM my_table
WHERE foo >= "blah blah blah" AND bar < 20"

You also pass pointers to variables that are to store the data received from the DB. Not sure about Access' exact syntax and how to specify it but I am sure that Access help files will tell you how.

The string is most likely passed in a two phase manner where you first pass the string and Access compiles it and return you a handle to the compiled query string. You then 'execute' that compiled query to perform it.

If you want to insert elements into the database you use INSERT instead of SELECT. In any case, the syntax of Access' SQL is also documented by microsoft in specific help files.

Note that access is a small database compared to other bigger databases so there are probably limitations to how advanced the query can be etc. However, for your simple application I doubt you will run into those kind of problems.

Is there any particular reason why you can't use ADO or ODBC?


Author Comment

ID: 8081036
I never mentioned not using ADO. The general idea is using SQL strings to execute all the commands on the Access database. I prefer not to use MFC since my MFC knowledge is zero and I've heard the entire MFC interface is crap. Is the entire ADO thing MFC based? I have used DAO in Visual Basic before but DAO is obsolete now and I need to use C++.

LVL 12

Accepted Solution

Salte earned 100 total points
ID: 8081547
ADO is MFC based as far as I know but ADO.NET is not. However, ADO.NET is .NET based so it require .NET framework.

However, when I say that ADO is MFC based it is perhaps not quite true. You can use it with MFC and visual studio is sort of geared up towards that. I believe though, that ADO can be used without dragging too much of other MFC stuff into the picture.

In this case I would suggest you look at ADO and if you have .NET framework you might want to check up on ADO.NET in that case you might even wanna check up on C# but C++ can also be used.


Assisted Solution

rkupka earned 100 total points
ID: 8082308
You can use ADO also from C++.
See http://www.codeguru.com/mfc_database/daoarticle.html
for example.
LVL 11

Expert Comment

ID: 9889580
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points split between Salte and rkupka

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).


-bcl (bcladd)
EE Cleanup Volunteer

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

762 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