行集(Rowsets)
行集是一个重要的对象,它使OLE DB组件以表格形式导出(expose)及操作数据。行集对象是行的集合,每行由数据列构成。
CoType TRowset {
[mandatory] interface IAccessor;
[mandatory] interface IColumnsInfo;
[mandatory] interface IConvertType;
[mandatory] interface IRowset;
[mandatory] interface IRowsetInfo;
[optional] interface IChapteredRowset;
[optional] interface IColumnsInfo2;
[optional] interface IColumnsRowset;
[optional] interface IConnectionPointContainer;
[optional] interface IDBAsynchStatus;
[optional] interface IGetRow;
[optional] interface IRowsetChange;
[optional] interface IRowsetChapterMember;
[optional] interface IRowsetCurrentIndex;
[optional] interface IRowsetFind;
[optional] interface IRowsetIdentity;
[optional] interface IRowsetIndex;
[optional] interface IRowsetLocate;
[optional] interface IRowsetRefresh;
[optional] interface IRowsetScroll;
[optional] interface IRowsetUpdate;
[optional] interface IRowsetView;
[optional] interface ISupportErrorInfo;
[optional] interface IRowsetBookmark;
}
创建行集
消费者可以使用如下方法之一获取行集对象:
- 在当前会晤对象中调用IOpenRowSet::OpenRowset直接创建行集对象。所有提供者都必须支持IOpenRowset接口。
- 在会晤对象中调用IDBCreateCommand::CreateCommand获取命令对象。然后在命令对象中调用ICommand::Execute。如果只有一个命令,返回结果行。例如一个SQL SELECT语句,ICommand::Execute返回一个行集,或消费者请求了IMultipleResults将返回多个结果对象。
- 消费者调用方法返回行集或计划行集(schema rowset)例如IColumnsRowset::GetColumnsRowset, IDBSchemaRowset::GetRowset, IViewRowset::OpenViewRowset, 或 ISourcesRowset::GetSourcesRowset.
- 消费者调用其它方法返回与行集类似的表格式的结果(returns tablular results as a rowset)。