[yunqa.de] TDISQLite3Database and DateTime format

  • From: edoardo falzetti <edoardo.falzetti@xxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 10 Feb 2010 10:21:10 +0100

I have a SQLite3 database on disk where dates are in TDataTime format stored as
float numbers.

Such dates are shown and edited in DBGrids and GanntCharts.

DBGrids
=======
0-Database => 1-TDISQLite3Database =>  2-TDISQLite3UniDirQuery =>
3-TDataSetProvider => 4-TClientDataSet => 5-TDataSource => 6-TDBGrid

The datetime fields of the ClientDataSet are TFloatFields; in the  OnGetText,
OnSetText methods of the ClientDataSet&#8217; fields i have the conversions:

Text:= DateTimeToStr(TDateTime(Sender.asFloat));
Sender.asFloat:= Double(StrToDateTime(Text));

It works fine (there is a better way anyhow?)



GanntCharts
===========

0-Database => 1-TDISQLite3Database =>  2-TDISQLite3UniDirQuery =>
3-TDataSetProvider => 4-TClientDataSet => 5-TDataSource => 6-TEzDataLink =>
7-TEzDataSet => 8-TDataSource => 9-TEzGanttChart

0- Database:  the datetime fields are floating numbers (REAL).

2- DISQLite3UniDirQuery InitFieldDef changes the type of the fields (ftFloat =>
ftDateTime)

4- ClientDataSet has persistent TDateTimeFields (they must be persistent)

6- EzDataLink using the persistent fields describes the relation father-child of
the records in the database (and  connects the fields of ClientDataSet with the
one of EzDataSet)


The PROBLEM i have is the following:
When i open the ClientDataset, TDISQLite3Database.sqlite3_cell16_asdatetime
interprets the persistent TDateTimeFields always as JulianDates. Besides that,
or as a consequence of that, i get then the exception: EIntOverflow (i.e. i do
not know if the problems are one or two)

The QUESTION is: how can i have persistent fields in the ClientDataset in
TDateTime format?


I send you a small project to show you the problem.

Notes:
1)
i&#8217;m working with the last version of DISQLite3.
2)
if there is no other way, the format of the data in the database can be changed
in the way you prefer but in the ClientDataset the persistent fields should be
TDateTime.

-- 
edoardo falzetti


_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: