Handling Notifications

Three interfaces provide notifications to their consumers: IDataSource, IRowPosition, and IRowset.

IDataSource and IDataSourceListener

A consumer implements IDataSourceListener to get notifications from an IDataSource object. IDataSourceListener is simple to implement because it is not a COM object and therefore does not require reference counting. A consumer calls IDataSource::AddDataSourceListener to add itself to the notification list, and IDataSource::RemoveDataSourceListener to remove itself from the notification list.

Refer to the IDataSource specification for more detail.

IRowPosition and IRowPositionChange

A consumer implements IRowPositionChange when it wants to know when the current row position is being changed. IRowPositionChange is a COM interface and therefore requires reference counting. A consumer needs to use QueryInterface on the IRowPosition object for its IConnectionPointContainer interface to add or remove its implementation of IRowPositionChange from the notification chain.

To facilitate the use of IConnectionPointContainer, consumers may choose to use the routines and classes implemented in Advcon.cpp and Advcon.h. See the Advise Connections section in Appendix B for more details.

IRowset and IRowsetNotify

A consumer implements IRowsetNotify to receive notifications from the rowset. A consumer needs to use QueryInterface on the IRowset object for its IConnectionPointContainer interface to add or remove its implementation of IRowsetNotify from the notification chain. Again, using the Advise Connections helpers will greatly simplify this process.

For more information about this topic, see the OLE DB Programmer’s Reference, Chapter 9, “Notifications.”