Solved

Master/Slave Tables in Delphi 7 using MSAccess DBs result in "not a valid timestamp" error/exception

Posted on 2004-08-18
10
313 Views
Last Modified: 2010-04-05
I have converted a Delphi 5 program to Delphi 7 which uses two MS Access tables, a master and a slave.  Each has a datetime field in the primary key, which correspond.

When I to a TTable.Insert on Table 1 (master), I get an exception "0.0 is not a valid timestamp".  The error occurs because Table 2 (slave) uses the datetime field in its master/slave key specifications.  I know this because if I unlink the two tables and do an insert on each of them, I get no error.

     TblTrustReq1.Open;
     TblTrustReq2.Open;
     TblTrustReq1.Append;
     TblTrustReq1CHKRequesterID.Value := 'KG';
     TblTrustReq1CHKRequesterDate.Value := Now;
     TblTrustReq1CHKCheckDate.Value := Now;

     TblTrustReq2.Append;
     TblTrustReq2CHKRequesterID2.Value := TblTrustReq1CHKRequesterID.Value;
     TblTrustReq2CHKDate.Value := TblTrustReq1CHKRequesterDate.Value;
     TblTrustReq2CHKSequence.Value := 1;

Can anyone help?

Keith
0
Comment
Question by:Kgondron
10 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
You're appending but not posting the changes. Any reasons why? Or did you forget to cut that part of the code. :)
0
 

Author Comment

by:Kgondron
Comment Utility
That comes later.  First I have to fill in other fields.  This bombs out immediately on doing the TblTrustReq1.Append;
KG
0
 

Author Comment

by:Kgondron
Comment Utility
Forget to mention:  I am using Reggatta's Titan for Access components to access the MS Access databases.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
Comment Utility
Your problem is that the function Now returns a TDateTime result whereas (judging from your error message) a Timestamp value is expected.

Use the following:
TblTrustReq1CHKRequesterDate.Value := DateTimeToTimeStamp(Now);
TblTrustReq1CHKCheckDate.Value := DateTimeToTimeStamp(Now);

The above assumes your Regatta component want a TTimestamp value.

If the above still doesn't work, your component probably doesn't support the delphi datatypes in which case you would have to convert your datetime value to an access date data type.

Kind regards
Pierre Cornelius
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Expert Comment

by:Pierre Cornelius
Comment Utility
Just another thought:

Try this:
TblTrustReq1CHKRequesterDate.AsDateTime := Now;
TblTrustReq1CHKCheckDate.AsDateTime := Now;

Regards
Pierre

0
 
LVL 6

Expert Comment

by:bpana
Comment Utility
you should post the changes on the first table before starting to modify the second one.

  TblTrustReq1CHKCheckDate.Value := Now;
  TblTrustReq1CHKCheckDate.Post;
...

but if you say that this line gives the error:
  TblTrustReq1.Append;
that should be something else.
0
 

Author Comment

by:Kgondron
Comment Utility
Nice try, guys, it's been so long ago that I got around this problem, it was hard to remember how it was solved.  Actually I contacted the Titan guy and he modified the Titan Access code because it had a bug in it.

Thanks anyway.
0
 

Accepted Solution

by:
PAQ_Man earned 0 total points
Comment Utility
PAQed with points refunded (500)

PAQ_Man
Community Support Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now