The IPB_ResultSetAccessor interface is used to access result sets in DataWindow and DataStore objects.
The IPB_ResultSetAccessor interface has six methods:
When you call the CreateResultSet function of interface IPB_Session, you need to pass an argument of type IPB_ResultSetAccessor. The AddRef function is called on that argument and the Release function is called when the pbobject is destroyed.
AddRef ( )
None.
Obtains the number of columns.
GetColumnCount ( )
Unsigned long.
This statement stores the number of columns in *numCols:
*numCols = d_rsAccessor->GetColumnCount();
Obtains a column's metadata. The column number of the first column is 1. Memory must be allocated for columnName before this function call. The pointer values can be null.
GetColumnMetaData (unsigned long columnNum, LPTSTR columnName, pbvalue_type* type, unsigned long* width )
Argument |
Description |
---|---|
columnNum |
The number of the column for which you want to obtain metadata |
columnName |
The name of the specified column |
type |
A pointer to the type of the specified column |
width |
A pointer to the width of the specified column |
None.
This example gets the number of columns in a result set and allocates an array to hold the types of each column:
CRsltSet::CRsltSet(IPB_ResultSetAccessor* rsAccessor) :m_lRefCount (0), d_rsAccessor(rsAccessor) { rsAccessor->AddRef(); // for each column ULONG nNumColumns = d_rsAccessor->GetColumnCount(); d_arrColTypes = new USHORT[nNumColumns + 1]; for (ULONG nColumn=1; nColumn <= nNumColumns; ++nColumn) { // get the column type into the array pbvalue_type type; d_rsAccessor->GetColumnMetaData (nColumn, NULL, &type, NULL); d_arrColTypes[nColumn] = (USHORT)type; } }
Accesses the data in a cell. The first row is 1 and the first column is 1.
GetItemData(unsigned long row, unsigned long col, IPB_RSItemData* data)
Argument |
Description |
---|---|
row |
The row number of the cell |
col |
The column number of the cell |
data |
A pointer to an IPB_RSItemData structure |
Boolean.
This example stores the data in the first row and column in the IPB_RSItemData structure sd:
d_rsAccessor->GetItemData(1, 1, &sd);
If the value of data is null,
this function issues the callback data->SetNull
.
If the value is not null, it issues the callback data->SetData
.
For more information, examine the IPB_RSItemData interface.
Obtains the number of rows.
GetRowCount ( )
Unsigned long.
This statement stores the number of rows in *numRows:
*numRows = d_rsAccessor->GetRowCount();
When you call the CreateResultSet function of interface IPB_Session, you need to pass an argument of type IPB_ResultSetAccessor. The AddRef function is called on that argument and the Release function is called when the pbobject is destroyed.
Release ( )
None.