Article ID: 217185 - View products that this article applies to.
This article was previously published under Q217185
This article has been archived. It is offered "as is" and will no longer be updated.
When an OLE DB Provider returns a DBSTATUS of DBSTATUS_S_ISNULL for a text field created using the ATL OLE DB Provider templates then the length of the field returned to the OLE DB consumer is not explicitly set to zero. This behavior follows the OLE DB specification, but can cause problems if an OLE DB consumer application utilizes the field length without checking the DBSTATUS of the column first. For example, a consumer application may assume that a non-zero field length means that the field is not NULL which is a common assumption when using text fields.
IRowsetImpl::GetData does not explicitly set the length for the column to zero if the DBSTATUS of the column is set to DBSTATUS_S_ISNULL.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:
194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
When implementing an CRowsetImpl derived class using the ATL OLE DB Provider template class, you can override the GetDBStatus function to provide DBSTATUS information for each field returned by the OLE DB Provider. If you return DBSTATUS_S_ISNULL from the GetDBStatus function for a particular field, this indicates to the OLE DB consumer that the particular field is NULL.
Internally, IRowsetImpl::GetData checks the DBSTATUS value you set for each field when returning the data to the consumer. If you set DBSTATUS to DBSTATUS_S_ISNULL, IRowsetImpl::GetData does not update the length indicator for a text field to 0. IRowsetImpl::GetData returns an unmodified length indicator to the client if you set the DBSTATUS of a field to DBSTATUS_S_ISNULL.
Steps to reproduce
If the Provider correctly updates the length indicator to zero when DBSTATUS_S_ISNULL is encountered, the following output for the FileName field should appear in the debug window:
If the Provider ignores the length indicator when DBSTATUS_S_ISNULL is encountered, then ActualSize will report some non-zero value.
Article ID: 217185 - Last Review: February 21, 2014 - Revision: 2.0