Microsoft Knowledge Base Email Alertz

Error C2039: 'GetAsDBTIMESTAMP' : is not a member of ATL::COleDateTime

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: 948938 - Last Review: February 8, 2008 - Revision: 1.2

Error C2039: 'GetAsDBTIMESTAMP' : is not a member of ATL::COleDateTime

Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

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
Keywords: 
kbnomt kbrapidpub KB948938
       

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