Home > Store

Sams Teach Yourself Database Programming with Visual C++ 6 in 21 Days

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Database Programming with Visual C++ 6 in 21 Days


  • Sorry, this book is no longer in print.
Not for Sale



Question 1: After inputting the listing from 9.8 into the ADOMFC1 project, ADOMFC1 will not compile, giving a "error C2027: use of undefined type 'DbComponent'", even though I added the #include directives for ATLTest1_i.c and ATLTest1.h as shown on page 178.

Solution 1: We have had no reports of there being any bugs, so it is probably in your code somewhere.

Try installing the source code off of the CD, and then compare your code with the ADOMFC1 code from the CD. Also compare your code to the ATLTest1 code from the CD. If anything is different between your code and the code off of the CD, that should enable you to find the problem.


  • Copyright 1998
  • Dimensions: 7.38 X 9.125
  • Pages: 600
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-31350-2
  • ISBN-13: 978-0-672-31350-9

In only 21 days, you'll have all the skills you need to get up and running efficiently. With this complete tutorial, you'll master the basics of database programming and then move on to the more advanced features and concepts. Understand the fundamentals of database programming in Visual C++. Master all the new and advanced database features that Visual C++6 offers. Learn how to effectively use the latest tools and features of Visual C++ for database programming by following practical, real-world examples. Get expert tips from a leading authority for programming your databases with Visual C++ 6 in the corporate environment.

Sample Content

Table of Contents

Who Should Read This Book. What You Will Need to Use This Book.


Day 1. Choosing the Right Database Technology.
Deciding the Appropriate Database Technology for Your Visual C++ Applications. Building Your Own Database in C++. Defining Metadata. A C++ Base Class to Handle the Database Work. Problems with Building Your Own Database. OLE Structured Storage. Record Managers (Btrieve). Desktop Databases (FoxPro and Access). Accessing ISAM Data over a LAN. Object Databases. Relational Database Servers (Oracle and SQL Server). How Do the Database Technologies Compare? Summary. Q&A. Workshop.

Day 2. Tools for Database Development in Visual C++ Developer Studio.
How to Build a Perfect Database Every Time. Support for the Relational Database Model in the Visual C++ Developer Studio. Installing the Database Components for Visual C++. Setting Up an ODBC Data Source for the Sample Database. Components of a Relational Database. Tables in a Relational Database. Fields in a Relational Database Table. Data Types in Relational Database Systems. Records in a Relational Database Table. Primary Keys in a Relational Database Table. Relationships between Records in Different Tables. Summary. Q&A. Workshop.

Day 3. Retrieving Data through Structured Query Language (SQL).
Structured Query Language. The SQL SELECT Statement. The ORDER BY Clause. The WHERE Clause. SQL Joins. SQL Subqueries. Resultsets and Cursors. Summary. Q&A. Workshop.

Day 4. Retrieving SQL Data through a C++ API.
Relational Database APIs. Microsoft Universal Data Access. ActiveX Data Objects (ADO). Techniques for Using ADO in C++ Applications. Building C++ Applications That Use ADO. Exception Handling for ADO. Displaying Records in a List Control. Summary. Q&A. Workshop.

Day 5. Adding, Modifying, and Deleting Data.
Cursor Types in ADO Recordsets. The ADO AddNew, Update, and Delete Functions. The AddNew Function. The Update Function. The Delete Function. The SQL INSERT, UPDATE, and DELETE Statements. The SQL INSERT Statement. The SQL UPDATE Statement. The SQL DELETE Statement. Summary. Q&A. Workshop.

Day 6. Harnessing the Power of Relational Database Servers.
Multitier Applications. How to Process Data at the Server. SQL Statements for Processing Data at the Server. The SQL INSERT Statement. The SQL UPDATE Statement. The SQL DELETE Statement. SQL Stored Procedures. C++ Tools for Processing Data at the Server. Calling Stored Procedures with ADO Command Objects. Calling Stored Procedures That Take Parameters. Summary. Q&A. Workshop.

Day 7. Database Design.
Database Normalization. Rules of Thumb for Relational Database Design. Normal Forms of the Relational Database Model. SQL Data Definition Language. Using Constraints and Indexes in a Relational Database. Tools and Techniques for Managing Relationships in a Relational Database. Using Constraints to Enforce Relationships. Summary. Q&A. Workshop.



Day 8. Utilizing the Capabilities of Database Servers.
Database Transactions. SQL Transaction Statements. Triggers to Execute SQL Code Automatically. SQL Aggregate Functions. COUNT. MAX, MIN, SUM, and AVG. Aggregate Functions and the GROUP BY Clause. SQL Views. Summary. Q&A. Workshop.

Day 9. Understanding COM.
The Limitations of Traditional Windows DLLs. What Win32 DLLs are and how they Work. The Limits of Using Win32 DLLs for Building Software Components. Building Software Components by Using COM. Using C++ Abstract Base Classes. Creating Objects by Using an API Function. COM Clients and COM Servers. COM Servers. The Active Template Library (ATL). IUnknown, QueryInterface, AddRef, and Release. Interface Definition Language. Automation (Formerly Called OLE Automation). COM Type Libraries. Summary. Q&A. Workshop.

Day 10. Database Client Technologies and the Secrets of ADO.
An Overview of Database Client Technologies. ODBC. MFC ODBC Classes. DAO. RDO. OLE DB. ADO. Database Client Technology Summary. The Secrets of ADO. ADO's History. ADO and COM. Summary. Q&A. Workshop.

Day 11. Multitier Architectures.
Layered Architecture. The OSI Model. Layered Architecture for Multitier Applications. Database Data and the Internet. CGI--The Original Technique for Interfacing Databases with Web Servers. DLLs and Server Scripts--An Improved Technique for Interfacing Databases with Web Servers. The XML Files. What Color of Edsel would you Like? Using ActiveX Controls and RDS to Build Elegant Thin Clients. Summary. Q&A. Workshop.

Day 12. Using Microsoft Transaction Server to Build Scalable Applications.
The Infrastructure for Multitier Applications. Using MTS to Build Multitier Applications. Where to Find MTS and How to Install It. How MTS Works in Multitier Applications. Managing MTS Components by Using Packages. Creating an MTS Component, Using Visual C++ and the ATL. Using the OLE-COM Viewer to Instantiate Your Component. Using the Windows Scripting Host to Test Your Component. Testing Your Component in an Active Server Page. Installing Your Component in MTS. Calling Your MTS Component from an Active Server Page. Returning an ADO Recordset from MTS Component to an Active Server Page. Debugging MTS Components. Summary. Q&A. Workshop.

Day 13. Melding Object-Oriented Programming with Relational Databases.
Relational Databases and Object-Oriented Languages, the Oil and Vinegar of Modern Application Development. How the Relational Model and the Object Model Differ. Object Databases versus Relational Databases. The Costs and Benefits of Using Relational Databases with C++. Techniques for Integrating Relational Databases with Object-Oriented C++ Programs. Begin by Designing the Relational Database. Create Simple Object/Relational Mappings. Create a Live Object Cache. Use the Strengths of Both Models. Summary. Q&A. Workshop.

Day 14. Legacy Database APIS.
ODBC. The ODBC Driver Administrator. The ODBC Driver Manager. The ODBC Driver. Programmatic Sequence for the ODBC API. Step 1: Connect to a Data Source. Step 2: Allocate a Statement Handle. Step 3: Prepare and Execute the SQL Statements. Step 4: Get the Results. Step 5: Committing the Transaction. A Simple Example. MFC Wrappers for ODBC. CDatabase. CRecordSet. DAO. The Jet Database Engine. CdbDBEngine: The Root of It All. CdbDBWorkspace. CdbDBDatabase. CdbDBRecordsets. MFC Wrappers for DAO. CDaoWorkspace. CDaoDatabase. CDaoRecordSet. A Simple Example. Summary. Q&A. Workshop.



Day 15. The ODBC API and the MFC ODBC Classes.
The Address Book. Using the MFC ODBC Wrapper Classes. Creating the Application. Getting Data. Updating the Application's Variables. Using the MFC DAO Wrapper Classes. Taking a Closer Look. Getting Data. Other DAO Classes. Summary. Q&A. Workshop.

Day 16. The Ultimate Database API: OLE DB.
An API for All Data Sources. The Components of an OLE DB Application. Making Data Sources Available. Comparing OLE DB to ODBC. The OLE DB Object Hierarchy. Enumerator. DataSource. Session. Command. Rowset. Index. Error. Transaction. Getting the Latest OLE DB Information. Summary. Q&A. Workshop.

Day 17. Accessing a Data Source with OLE DB.
Data Consumers and Providers. Interfaces. Interface Factoring. Interface Negotiations. OLE DB Application Flow. Enumerators. The IParseDisplayName Interface. The ISourcesRowset Interface. The IDBInitialize Interface. The IDBProperties Interface. The ISupportErrorInfo Interface. Using an Enumerator: A Simple Example. The DataSource Object. The IDBCreateSession Interface. The IDBDataSourceAdmin Interface. The IDBInfo Interface. The IPersist Interface. The IPersistFile Interface. Connecting to a DataSource Object. The OLE DB ODBC Provider. Example: Connecting to an OLE DB ODBC Data Source. Summary. Q&A. Workshop.

Day 18. Querying a Data Source with OLE DB.
Sessions. The IGetDataSource Interface. The IOpenRowset Interface. The ISessionProperties Interface. The IDBCreateCommand Interface. The IDBSchemaRowset Interface. The ITableDefinition Interface. The IIndexDefinition Interface. The ITransaction, ITransactionJoin, ITransactionLocal, and ITransaction Object Interfaces. Commands. The IAccessor Interface. The IColumnsInfo Interface. The ICommand Interface. The ICommandProperties Interface. The ICommandText Interface. The IConvertType Interface. The IColumnsRowset Interface. The ICommandPrepare Interface. The ICommandWithParameters Interface. A SQL Compendium. SQL Queries--Data Manipulation Language. SELECT. Clauses. INSERT INTO. UPDATE. DELETE. SQL--Data Definition Language. CREATE. ALTER. DROP. Creating and Executing Commands. Creating and Executing a Command. Accessors. Elements of a Parameter Accessor. Command Parameters. Multiple Resultsets. Summary. Q&A. Workshop.

Day 19. Navigating the Result of a Query.
Rowset Interfaces. The IRowset Interface. The IRowsetInfo Interface. The IConnectionPointContainer Interface. The IRowsetChange Interface. The IRowsetIdentity Interface. The IRowsetLocate Interface. The IRowsetResynch Interface. The IRowsetScroll Interface. The IRowsetUpdate Interface. The Six-Step Plan to Retrieving Data. Creating Bindings. Row Set Accessors. Retrieving Rows and Columns. Navigation. Bookmarks. Deferred Access. Column Types. BLOBs. Unicode String Processing. Cursors. Static Cursors. KeySet Cursors. Dynamic Cursors. Summary. Q&A. Workshop.

Day 20. Properties, Transactions, and Indexes.
Properties and Groups. Getting Properties. Setting Properties. A Review of OLE DB Object Properties. Transactions. The ITransaction Interface. The ITransactionLocal Interface. The ITransactionOptions Interface. The ITransactionObject Interface. The ITransactionJoin Interface. Creating Transactions. Committing and Aborting Transactions. Nesting Transactions. Isolation Levels and Locking. The Index Object. The IRowsetIndex Interface. Using the Index Object. Summary. Q&A. Workshop.

Day 21. OLE DB Error Handling.
Basic Error Handling. Checking Error Results. Automation Error Objects. The ISupportErrorInfo Interface. The IErrorInfo Interface. OLE DB Error Objects. The IErrorRecords Interface. The IErrorLookup Interface. The ISQLErrorInfo Interface. The Completed DispErrorInfo Source Code. How to Integrate the DispErrorInfo Procedure. Error-Handling Considerations. Returning Error Objects. Threads. A Summary of OLE DB HRESULT Error Codes. Summary. Q&A. Workshop.


Appendix A. What's on the CD?
Appendix B. Additional Resources.
Appendix C. Installing the Microsoft Data Access Components.
Appendix D. Interpreting Results.
Appendix E. Using ADO via the OLE DB SDK.
Appendix F. Answers.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020