The help you needed in C, C++, MFC
Complete tutorials with free source code

Database access using C++ MFC classes

This tutorial shows you how to connect to a database in C++, and manipulate data in the database.

Applications need to keep stores of data in disk. Normal applications we use achieve this by simply creating files in disk and storing data in these files. Application may use its own format and its own file extension for these files. But, in business applications, it is easier to use a suitable database for storing the data.

Each database has its own interface to connect with it. It is difficult to a person to learn how to work with each database available. So, to solve this problem, Microsoft has introduced Open Data Base Connectivity (ODBC) which is a standard interface which can be used to connect to various databases. A program can connect to a database using ODBC interface and issue ODBC function calls to communicate with the database. Then ODBC interface implemented in the Windows operating system converts these function calls to database specific function calls and carry out the requested operations with the database. So who actually connects to the database is ODBC interface.

MFC classes has two classes which are very useful to connect to a database using ODBC. They are CDatabase and CRecordSet. Here you can find articles which explain how to use these classes to connect to a database and how to carry out various database operations.

A simple database application using MFC application wizard
How to execute custom SQL queries