Microcomputers became popular, in part, because businesspeople saw them as a low-cost means of tracking inventory, processing orders, printing payroll checks, and so forth. Business applications required fast access to individual records in a large database. One of the first microcomputer database tools was dBASE II, a single-user product with its own programming language and file format. Today Windows programmers have a wide choice of programmable database management systems (DBMS's), including Inprise Paradox, Microsoft Access, Microsoft FoxPro, and Powersoft PowerBuilder. Most of these products can access both local data and remote data on a central computer. The latter case requires the addition of database server software such as ORACLE or Microsoft SQL Server.
Microsoft SQL Server is included with the Enterprise Edition of Visual C++.
How do you, as an MFC programmer, fit into the picture? Visual C++ contains all the components you'll need to write C++ database applications for Microsoft Windows. Indeed, the product contains two separate client-side database access systems: Open Database Connectivity (ODBC) and Data Access Objects (DAO). In addition, Visual C++ now contains wrapper templates for interacting with data directly through OLE DB. This chapter covers the ODBC standard, which consists of an extensible set of dynamic link libraries (DLLs) that provide a standard database application programming interface. ODBC is based on a standardized version of Structured Query Language (SQL). With ODBC and SQL, you can write database access code that is independent of any database product.
Visual C++ includes tools and MFC classes for ODBC, and that's the subject of this chapter. You'll learn the basics of ODBC, and you'll see four sample programs: one that uses the ODBC rowset with support from the MFC CRecordset class (EX31A), one that uses the MFC CRecordView class (EX31B), one that uses multiple recordsets (EX31C), and one that uses the CRecordset class without binding (EX31D).