次の方法で共有


DAO Collections: Obtaining Information About DAO Objects

OverviewHow Do IFAQSampleODBC Driver List

Objects of most of the MFC DAO classes contain “collections” of subordinate objects. For example, a object contains collections of tabledefs, querydefs, and relations. For an explanation of how these collections fit into the MFC implementation, see the article DAO Collections.

The present article explains how to obtain information about the objects in a collection. The example given uses the database object’s QueryDefs collection, but the same mechanism applies to other collections throughout the MFC implementation of DAO.

Topics covered include:

Functions for Accessing DAO Collections

Access the objects in a DAO collection through the GetXCount and GetXInfo member functions of the appropriate class, where X stands for Database, Field, Index, Parameter, Query, Table, Relation, or Workspace. The following table lists the available collection-access functions for each MFC class.

Class Member Functions for Accessing Collections

Class Count objects in collection Get information about a specified object
,                ,
, , , ,
, ,
, ,
, ,

Information Returned by the GetXInfo Functions

In general, use GetXCount functions to determine the upper bound for looping through a collection. On each iteration of the loop, call GetXInfo functions to retrieve the information. The GetXInfo functions return a reference to an object of class CDaoXInfo, which you can examine. Each different CDaoXInfo class (technically a C++ structure) supplies different information. You pass an object of type CDaoXInfo in the second (xinfo) parameter.

****Note   ****DAO collections are zero-based. When you iterate a collection, begin with element 0.

The following table lists the CDaoXInfo classes. See the class for details about its members.