Error C2039: ‘GetAsDBTIMESTAMP’ : is not a member of ATL::COleDateTime

Action

1. Open Visual Studio 2005 or 2008 and create default MFC Single Document application.
2. Add the following code in the OnDraw() method of the wizard-generated custom view class:
COleDateTime t = COleDateTime::GetCurrentTime();
DBTIMESTAMP ts;
t.GetAsDBTIMESTAMP( ts ); // retrieves the time in t into the ts structure
3. Now compile the project.


Result

You receive the following error:
“testoleview.cpp(59) : error C2039: ‘GetAsDBTIMESTAMP’ : is not a member of ‘ATL::COleDateTime’
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\atlmfc\include\atlcomtime.h(104) : see declaration of
‘ATL::COleDateTime'”
[Even including the required header files in the View class does not resolve the error:
#include <oledb.h>
#include <ATLComTime.h>]


Cause

Only ATLComTime.h was included indirectly from #include <afxdisp.h>, which was added in stdafx.h by the wizard while generating the default code for the project.  But for GetAsDBTIMESTAMP to be compiled as part of COleDateTime, __oledb_h__ must have been defined previously. Even if Database support was selected in the wizard during project generation, afxoledb.h is added to stdafx.h, but it is added after afxdisp.h, which is too late.


Resolution

Move the #include <afxoledb.h> above the #include <afxdisp.h> in the precompilation header file, stdafx.h.


More Information

This bug has been reported, and may be fixed in a later Service Pack.


DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.



APPLIES TO
Microsoft Visual Studio 2005 Express Edition
Microsoft Visual Studio 2005 Professional Edition
Microsoft Visual Studio 2005 Service Pack 1
Microsoft Visual Studio 2005 Standard Edition
Microsoft Visual Studio 2005 Team Suite
Microsoft Visual Studio 2008 Academic Edition
Microsoft Visual Studio 2008 Professional Edition
Microsoft Visual Studio 2008 Standard Edition
Microsoft Visual Studio Team System 2008 Team Suite

——————————————–

Microsoft Knowledge Base Article

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

 


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image