- Table of Contents
- Copyright
- About the Authors
- About the Contributors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- How to Use This Book
- What You Need to Use This Book
- What's New in Visual C++ 6.0
- Contacting the Main Author
- Part I: Introduction
- Chapter 1. The Visual C++ 6.0 Environment
- Part II: MFC Programming
- Chapter 2. MFC Class Library Overview
- Chapter 3. MFC Message Handling Mechanism
- Chapter 4. The Document View Architecture
- Chapter 5. Creating and Using Dialog Boxes
- Chapter 6. Working with Device Contexts and GDI Objects
- Chapter 7. Creating and Using Property Sheets
- Chapter 8. Working with the File System
- Chapter 9. Using Serialization with File and Archive Objects
- Part III: Internet Programming with MFC
- Chapter 10. MFC and the Internet Server API (ISAPI)
- Chapter 11. The WinInet API
- Chapter 12. MFC HTML Support
- Part IV: Advanced Programming Topics
- Chapter 13. Using the Standard C++ Library
- Chapter 14. Error Detection and Exception Handling Techniques
- Chapter 15. Debugging and Profiling Strategies
- Chapter 16. Multithreading
- Chapter 17. Using Scripting and Other Tools to Automate the Visual C++ IDE
- Part V: Database Programming
- Chapter 18. Creating Custom AppWizards
- Chapter 19. Database Overview
- Chapter 20. ODBC Programming
- Chapter 21. MFC Database Classes
- Chapter 22. Using OLE DB
- Chapter 23. Programming with ADO
- ADO Objects
- Connection Objects
- ADOCommand Objects
- ADORecordset Objects
- ADOFields Collections and ADOField Objects
- ADOParameter Objects and the ADOParameters Collection
- ADOProperty Objects and ADOProperties Collections
- Writing a Visual C++ ADO Application
- Processing ADO Errors
- Enhanced ADO Recordset Functionality
- Executing Commands
- Transactions
- Summary
- Part VI: MFC Support for COM and ActiveX
- Chapter 24. Overview of COM and Active Technologies
- Chapter 25. Active Documents
- Chapter 26. Active Containers
- Chapter 27. Active Servers
- Chapter 28. ActiveX Controls
- Part VII: Using the Active Template Library
- Chapter 29. ATL Architecture
- Chapter 30. Creating COM Objects Using ATL
- Chapter 31. Creating ActiveX Controls Using ATL
- Chapter 32. Using ATL to Create MTS and COM+ Components
- Part VIII: Finishing Touches
- Chapter 33. Adding Windows Help
- Part IX: Appendix
ADORecordset Objects
ADORecordset objects provide most of your interactions with the data. They are used to contain a set of records returned from the datasource. You can open a recordset directly by calling its Open() method, or you can generate a recordset by calling Execute() on a Connection or Command object.
The Recordset object represents all the rows returned from the data source, although you might work with only one row at a time—the current row. The data in a row is manipulated by working with the Field objects contained in the recordset's Fields collection.
ADORecordset Properties
All ADORecordset objects have the following properties. Most of these can be used to set or retrieve information about the current state of the recordset, and setting others can perform operations, such as scrolling, on the recordset:
- AbsolutePage is used to move the current row to the start of a specified page of rows. The number of rows in a page is set in the PageSize property.
- AbsolutePosition is used to make a row at the specified absolute position the current row.
- ActiveConnection is used to specify the connection that is to be used for the recordset. This can reference an existing connection, or you can pass a connection string for a new connection that will be created for this recordset.
- BOF is true if the recordset is currently positioned before the first row.
- EOF is true if the recordset is positioned after the last row.
- Bookmark contains the bookmark for the current row.
- CacheSize specifies the number of rows of data that will be cached in local memory.
- CursorType specifies the type of cursor that is used with this recordset. The cursor can be a forward-only, keyset, static, or dynamic cursor.
- EditMode indicates whether the current row has been modified since being fetched, or whether it is a new row that has not yet been written to the data source.
- Filter specifies a filter for the rows that will be visible in the recordset. This can specify a SQL WHERE clause, an array of bookmarks, or a constant enabling you to view only pending, affected, or fetched records.
- LockType specifies the locking mechanism used when the provider opens the rows in the recordset.
- MaxRecords can be used to specify the maximum number of rows that will be returned in a recordset.
- PageCount indicates how many pages of rows are present in the recordset, based on the PageSize property.
- PageSize specifies the number of rows in a page. This is used in conjunction with the PageCount and AbsolutePage properties.
- RecordCount indicates the number of rows currently in the recordset.
- Source specifies where the data in the recordset comes from. This can be a Command object, SQL statement, stored procedure, or table name.
- Status indicates the status of the current row after a batch update or other bulk operations.
ADORecordset Methods
ADORecordset objects also expose the following methods:
- AddNew is used to create a new row in the recordset.
- CancelBatch cancels a batch update in progress.
- CancelUpdate cancels any changes made to the current row.
- Clone creates a new recordset that is a duplicate of the current recordset.
- Close closes the recordset.
- Delete deletes one or more records from the recordset.
- GetRows is used to fetch a block of rows into an array.
- Move sets the current row of the recordset.
- MoveFirst makes the first row of the recordset the current row.
- MoveLast makes the last row of the recordset the current row.
- MoveNext positions the recordset on the next row.
- MovePrevious positions the recordset on the previous row.
- NextRecordset is used to move to the next recordset returned by compound queries. This clears the recordset and returns the data for the next recordset generated.
- Open is used to open a recordset directly, rather than as a result of methods from other objects, such as Commands or Connections.
- Requery refreshes the data in the recordset by re-executing the query that gen- erated it.
- Resync updates the data for any rows in the recordset with the most current data from the datasource. However, this does not return any new rows, as Requery does.
- Supports is used to determine whether the recordset supports a variety of different operations, including bookmarks, modifying the data, and batch updates, among other things.
- Update is used to submit any changes made to the current row to the datasource.
- UpdateBatch submits any changes made in the current batch update to the datasource.
ADOFields Collections and ADOField Objects | Next Section

Account Sign In
View your cart