Microsoft Knowledge Base Email Alertz

When using ActiveX Data Objects (ADO) against certain OLE DB providers, you may find that recordset fields that should be NULL do not test for NULL correctly either by checking the VARIANT.vt value for VT_NULL (in Microsoft Visual C++) or b

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 308037 - Last Review: September 26, 2005 - Revision: 2.2

FIX: ADO GetValue Does Not Check DBSTATUS_S_ISNULL for VARIANT

This article was previously published under Q308037

SYMPTOMS

When using ActiveX Data Objects (ADO) against certain OLE DB providers, you may find that recordset fields that should be NULL do not test for NULL correctly either by checking the VARIANT.vt value for VT_NULL (in Microsoft Visual C++) or by using IsNull (in Microsoft Visual Basic).

CAUSE

Certain OLEDB providers may not set the VARIANT.vt field of VARIANT values in a rowset to VT_NULL for NULL values. According to the OLE DB specification, this behavior is correct; the only responsibility of the provider is to set the dwStatus field of the accessor's bindings to DBSTATUS_S_ISNULL.

Because ADO is an OLE DB consumer, it has the responsibility to check this dwStatus value and if necessary set the VARIANT.vt field of VARIANT values in the recordset to VT_NULL. Because the current versions of ADO do not check this dwStatus value, an ADO programmer checking the VARIANT.vt field of a VARIANT value in an ADO recordset will not be able to correctly determine if the VARIANT value is NULL.

Although it is not the provider's responsibilty to set the VARIANT.vt field of VARIANT datatypes to VT_NULL, most providers, including Microsoft OLEDB Provider for SQL Server (SQLOLEDB), Microsoft OLEDB Provider for ODBC Driver (MSDASQL), Microsoft Jet OLEDB Provider (MSJETOLEDB40), and the Microsoft Oracle OLEDB Provider (MSDAORA) will set the dwStatus of the accessor's bindings to DBSTATUS_S_ISNULL and will also set the VARIANT.vt field to VT_NULL. Therefore, with these providers ADO will behave as expected. However, with providers who do not set this datatype to VT_NULL, you could face this problem.

RESOLUTION

To resolve this problem, obtain the latest service pack for SQL Server 2000, the latest service pack for MDAC 2.6, or the hotfix referenced below. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
290211  (http://kbalertz.com/Feedback.aspx?kbNumber=290211/EN-US/ ) INF: How to Obtain the Latest SQL Server 2000 Service Pack
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
300635  (http://kbalertz.com/Feedback.aspx?kbNumber=300635/EN-US/ ) INFO: How to Obtain the Latest MDAC 2.6 Service Pack

Hotfix

The English version of this fix should have the following file attributes or later:
 Date         Version       Size      File name     Platform
 -----------------------------------------------------------
 21-SEP-2001  2.61.7921.0   528,656   Msado15.dll   x86
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in SQL Server 2000 Service Pack 2 and MDAC 2.6 Service Pack 2.

APPLIES TO
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Data Access Components 2.6
Keywords: 
kbhotfixserver kbqfe kbbug kbfix kbmdac260sp2fix kbsqlserv2000presp2fix KB308037
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate