Description
New interfaces and functions have been added to PBNI to enable you to access the data in a DataWindow or DataStore.
Usage
Three new functions have been added to the IPB_Session interface in pbni.h:
- virtual pbobject CreateResultSet(IPB_ResultSetAccessor* rs)
Creates a resultset from C++. The argument is a pointer to the new interface IPB_ResultSetAccessor.
- virtual IPB_ResultSetAccessor* GetResultSetAccessor(pbobject rs)
Given a resultset powerobject, call this function to get an interface through which you can read data.
- virtual void ReleaseResultSetAccessor(IPB_ResultSetAccessor* rs)
Releases the pointer obtained using GetResultSetAccessor.
A new header file, IPB_ResultSetAccessor.h, declares the interface IPB_ResultSetAccessor and some related structures.
The IPB_ResultSetAccessor interface includes six functions:.
- virtual void AddRef(), virtual void Release()
When you call the CreateResultSet function of interface IPB_Session, you need to pass an argument of IPB_ResultSetAccessor. The AddRef function is called on that argument and the Release function is called when the pbobject is destroyed.
- virtual unsigned long GetRowCount(), virtual unsigned long GetColumnCount()
These functions get the number of rows and columns
- virtual void GetColumnMetaData(unsigned long columnNum, LPTSTR columnName, pbvalue_type* type, unsigned long* width)
This function obtains a column's metadata. The first column is 1. Memory must be allocated for columnName before this function call. All pointers could be null.
- virtual bool GetItemData(unsigned long row, unsigned long col, IPB_RSItemData* data)
Use this function to access the data in a cell. The first row is 1 and the first column is 1.
If the value 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_RSCellData interface.
The IPB_ResultSetAccessor.h file defines three structures: PB_DateData, PB_TimeData, and PB_DateTimeData. These structures are used to pass data in the SetData function of the IPB_RSCellData interface.
The IPB_RSCellData interface is used as an argument to the GetItemData function of IPB_ResultSetAccessor. This interface has two functions:
- SetNull
This function is called when the value of the cell is null.
- SetData(unsigned long len, void* data)
This function is called when the value of the cell is not null. The first argument is the data length and the second is the address of the data.
If the cell datatype is:
- string and decimal, the address points to a string
- date, the address points to a structure PB_DateData
- time, the address points to a structure PB_TimeData
- datetime, the address points to a sturcture PB_DateTimeData
- another datatype, the address points to a data of corresponding type
For more information, see the online Help for PBNI.
|