Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I read in a date from a database???

Posted on 1998-10-09
6
Medium Priority
?
136 Views
Last Modified: 2013-11-20
I can read in fields of all types (CString, int, etc) in a database, but I cannot get the dates (AppWiz defined the date as CTime in the CRecordset derived class) to work properly.  Anyone have any suggestions please??  BTW, I'm using Access 97 and Visual C++ 6.0
0
Comment
Question by:rgeiman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:rgeiman
ID: 1323148
Edited text of question
0
 

Author Comment

by:rgeiman
ID: 1323149
Adjusted points to 150
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1323150
Just guessing ... Try changing the type to COleDateTime ( i think Access uses the OLE DATE
type, which must be mapped to COleDateTime instead of CTime, but i am not sure).

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:rgeiman
ID: 1323151
Edited text of question
0
 
LVL 7

Accepted Solution

by:
psdavis earned 450 total points
ID: 1323152
You're right snoegler!  COleDateTime is almost the only way to use dates with Access.  Here's a code snipplet that set's the time in my dao table to the current time.

pSearchJobsSet->Edit( );
pSearchJobsSet->m_Start_Time = COleDateTime::GetCurrentTime( );
pSearchJobsSet->Update( );

The opposite *should* be absolutely true.  Here's a pseudo-code to read the same date...

COleDateTime dtStartTime;
dtStartTime = pSearchJobsSet->m_Start_Time;

Phillip
0
 

Expert Comment

by:umarama
ID: 1323153
It's O.K. to use CTime. I have used it with CRecordsets.
CTime gives problems (usually invalid memory reference) when the object is not initialized and the database defaults to one (say to Now()). Try initializing your CTime object to either 0 or CTime::GetCurrentTime(). Basically, initialize it to some value !


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question