Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can retrieve the length of a variable-length column or the status of a column (to check for DBSTATUS_S_ISNULL, for example).
To get the length, use the COLUMN_ENTRY_LENGTH macro.
To get the status, use the COLUMN_ENTRY_STATUS macro.
To get both, use COLUMN_ENTRY_LENGTH_STATUS, as shown below.
class CProduct
{
public:
char szName[40];
long nNameLength;
DBSTATUS nNameStatus;
BEGIN_COLUMN_MAP(CProduct)
COLUMN_ENTRY_LENGTH_STATUS(2, szName, nNameLength, nNameStatus)
END_COLUMN_MAP()
};
CTable<CAccessor<CProduct > > product;
product.Open(session, "Product");
while (product.MoveNext() == S_OK)
{
// Check the product name isn’t NULL before tracing it
if (product.nNameStatus == DBSTATUS_S_OK)
ATLTRACE(“%s is %d characters\n”, szName, nNameLength);
}
When you use CDynamicAccessor, the length and status are bound for you automatically. To retrieve the length and status values, use the GetLength and GetStatus member functions.