Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Delphi XE application storing into Paradox database (bde) issue


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Jun 20, 2016 6:26 AM Last Post By: Michael Hackney
Michael Hackney

Posts: 28
Registered: 9/4/14
Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2016 6:18 AM
Why is my Delphi XE application storing to a Paradox database (BDE) into a Time field as 12:11:33 AM for every record. The Date Field is storing today's date into the date field correctly, but the TimeField which has a Time field type always displays 12:11:33 AM for every new record created.

Here's the code:

MyDatasourceDateField.AsDateTime := Date;
MyDatasourceTimeField.AsDateTime := Time;
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2016 10:26 AM   in response to: Michael Hackney in response to: Michael Hackney
Michael Hackney wrote:

Why is my Delphi XE application storing to a Paradox database (BDE)
into a Time field as 12:11:33 AM for every record. The Date Field is
storing today's date into the date field correctly, but the TimeField
which has a Time field type always displays 12:11:33 AM for every new
record created.

Here's the code:

MyDatasourceDateField.AsDateTime := Date;
MyDatasourceTimeField.AsDateTime := Time;

I would suspect that "Time" in this case is not the Time function from
Sysutils you want to call but some constant in your code.

--
Peter Below
TeamB
Michael Hackney

Posts: 28
Registered: 9/4/14
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2016 12:17 PM   in response to: Peter Below in response to: Peter Below
Peter Below wrote:
Michael Hackney wrote:

Why is my Delphi XE application storing to a Paradox database (BDE)
into a Time field as 12:11:33 AM for every record. The Date Field is
storing today's date into the date field correctly, but the TimeField
which has a Time field type always displays 12:11:33 AM for every new
record created.

Here's the code:

MyDatasourceDateField.AsDateTime := Date;
MyDatasourceTimeField.AsDateTime := Time;

I would suspect that "Time" in this case is not the Time function from
Sysutils you want to call but some constant in your code.

--
Peter Below
TeamB

I want to take the current time and store that value as a Date/Time value in MyDatasourceTimeField. So I would think I want the Time function from Sysutils. It's just that right now, for some reason when then code executes, for every record it stores the time value of 12:11:33 AM in that field, regardless of the time of day.
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 10, 2016 12:15 AM   in response to: Michael Hackney in response to: Michael Hackney
MyDatasourceTimeField.AsDateTime := Time;
I want to take the current time and store that value as a Date/Time value in MyDatasourceTimeField.
So I would think I want the Time function from Sysutils.

Use then MyDatasourceTimeField.AsDateTime := SysUtils.Time tio be sure..

Maybe the SysUtils.Time is fine but the use of AsDateTime is maybe bugging you.
Did you try MyDatasourceTimeField.AsSQLTimeStamp:=Time ?

for every record it stores the time value of 12:11:33 AM in that field
Maybe because there is still a Date part added when you use AsDateTime.

If nothing works you have to find a way to get the time details from SysUtils.Time (DecodeDateTime, EncodeDateTime)
and create your valid time part for BDE Paradox table, create a valid string for it and use MyDatasourceTimeField.AsString
Normally Date and Time are Integers in the Table, so maybe you have to convert the Time to a valid
Integer number for Paradox Table and use MyDatasourceTimeField.AsInteger

Edited by: Robert Triest on Jun 10, 2016 9:54 AM
Michael Hackney

Posts: 28
Registered: 9/4/14
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 13, 2016 6:05 AM   in response to: Robert Triest in response to: Robert Triest
I tried those different options, but none of them worked. I did add a message dialog to see what the Time was and it show 12/30/1899. What else should I try?

ShowMessage('Time is ' + DateToStr(Time));


Robert Triest wrote:
MyDatasourceTimeField.AsDateTime := Time;
I want to take the current time and store that value as a Date/Time value in MyDatasourceTimeField.
So I would think I want the Time function from Sysutils.

Use then MyDatasourceTimeField.AsDateTime := SysUtils.Time tio be sure..

Maybe the SysUtils.Time is fine but the use of AsDateTime is maybe bugging you.
Did you try MyDatasourceTimeField.AsSQLTimeStamp:=Time ?

for every record it stores the time value of 12:11:33 AM in that field
Maybe because there is still a Date part added when you use AsDateTime.

If nothing works you have to find a way to get the time details from SysUtils.Time (DecodeDateTime, EncodeDateTime)
and create your valid time part for BDE Paradox table, create a valid string for it and use MyDatasourceTimeField.AsString
Normally Date and Time are Integers in the Table, so maybe you have to convert the Time to a valid
Integer number for Paradox Table and use MyDatasourceTimeField.AsInteger

Edited by: Robert Triest on Jun 10, 2016 9:54 AM
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 13, 2016 7:03 AM   in response to: Michael Hackney in response to: Michael Hackney
Michael Hackney wrote:

I tried those different options, but none of them worked. I did add
a message dialog to see what the Time was and it show 12/30/1899.
What else should I try?

ShowMessage('Time is ' + DateToStr(Time));

Of course its 12/30/1899 as it displays the date part of the Time. You
should use TimeToStr:

 ShowMessage('Time is ' + TimeToStr(Time));
Michael Hackney

Posts: 28
Registered: 9/4/14
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 13, 2016 8:21 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Yeah sorry. The code below does report the correct time in the message, but it still posts 12:11:33 AM in the database for this Time field which is posted to the database in the very next line in my code.

ShowMessage('Time is ' + TimeToStr(Time));


Lajos Juhasz wrote:
Michael Hackney wrote:

I tried those different options, but none of them worked. I did add
a message dialog to see what the Time was and it show 12/30/1899.
What else should I try?

ShowMessage('Time is ' + DateToStr(Time));

Of course its 12/30/1899 as it displays the date part of the Time. You
should use TimeToStr:

 ShowMessage('Time is ' + TimeToStr(Time));
Michael Hackney

Posts: 28
Registered: 9/4/14
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 14, 2016 7:04 AM   in response to: Michael Hackney in response to: Michael Hackney
Michael Hackney wrote:
Yeah sorry. The code below does report the correct time in the message, but it still posts 12:11:33 AM in the database for this Time field which is posted to the database in the very next line in my code.

ShowMessage('Time is ' + TimeToStr(Time));


Lajos Juhasz wrote:
Michael Hackney wrote:

I tried those different options, but none of them worked. I did add
a message dialog to see what the Time was and it show 12/30/1899.
What else should I try?

ShowMessage('Time is ' + DateToStr(Time));

Of course its 12/30/1899 as it displays the date part of the Time. You
should use TimeToStr:

 ShowMessage('Time is ' + TimeToStr(Time));

Update: I have added code to post the current time to a second table right after the first (original) one, and the app posts the correct current time to the second table, but still 12:11:33 AM to the first one. I also restructured the original table and modified the Time field in question, making it a AlphaNumeric field, and then set it back to a Time field type again, but no luck. Could the original table be corrupted? I'm getting the correct system Time, but when I try to post it to that field in the table it always produces 12:11:33 AM. Thoughts???
Frank Marousek

Posts: 14
Registered: 10/9/06
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2016 11:51 AM   in response to: Michael Hackney in response to: Michael Hackney
Is there possibly code in either MyDatasource.BeforePost or in
MyDatasourceTimeField.OnValidate that might be altering the value before
the record is posted?
Michael Hackney

Posts: 28
Registered: 9/4/14
Re: Delphi XE application storing into Paradox database (bde) issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 20, 2016 6:26 AM   in response to: Frank Marousek in response to: Frank Marousek
Frank Marousek wrote:
Is there possibly code in either MyDatasource.BeforePost or in
MyDatasourceTimeField.OnValidate that might be altering the value before
the record is posted?

No, there is no BeforePost or OnValidate routine.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02