Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread WinCE Date problem
Sun, Jun 6 2010 1:41 AMPermanent Link

Bill Z

ZED Data Solutions

Using ElevateDB 2.03 Build 13
Lazarus 0.9.28.2

Newbie to ElevateDB/Lazarus. I need to insert some data from a Firebird database (on PC) to an ElevateDB database on wince.  The problem I am having is with a date field on the ElevateDB side. I am aware that the Firebird fbclient.dll for wince does have problems with date fields so to overcome this I have added a date string field in the appropriate table on the main database (PC) with the idea to convert to a date value (DateToStr) in the wince program (and vice versa when I need to go the other way).  So on the wince program have a query to get the data from the PC and loop through (while not Eof) to transfer the data. I create a variable dNextFill of type tDate and do the following inside the while...loop:

while not PDADataModule.FillSchedQry.EOF do
begin
   dNextFill := StrToDate(PDADataModule.FillSchedQry.FieldByName('NEXTFILLSTR').AsString);
   PDADataModule.FillSchedTbl.Insert;
   PDADataModule.FillSchedTbl.FieldByName('MachID').asInteger :=
                 PDADataModule.FillSchedQry.FieldByName('MACHID').asInteger;
   PDADataModule.FillSchedTbl.FieldByName('SiteID').asInteger :=
                 PDADataModule.FillSchedQry.FieldByName('SITEID').asInteger;
   PDADataModule.FillSchedTbl.FieldByName('FillDate').AsDateTime := dNextFill;
   PDADataModule.FillSchedTbl.FieldByName('Filled').asBoolean := False;
   PDADataModule.FillSchedTbl.Post;
   PDADataModule.FillSchedQry.Next;
 end;       

Every time it gets to the poit where dNextFill is assigned to the table field I get the following message.

'Bus error or misaligned data access.'

Have tried using the 'unaligned' keyword as suggested in one of the lazarus wiki's but that doesn't do anything for my problem. Not sure whether the problem is ElevateDB or Lazarus but as it is happenning when assigning a value to an ElevateDB table.....give you a try first.

Any help will be appreciated.

regards

Bill Zwirs
Sun, Jun 6 2010 5:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

<< Every time it gets to the poit where dNextFill is assigned to the table
field I get the following message.

'Bus error or misaligned data access.'

>>

If the FillSchedQry a Firebird query component, or an ElevateDB query
component ?  If the former, then the alignment issue is on the Firebird
component end.

--
Tim Young
Elevate Software
www.elevatesoft.com
Sun, Jun 6 2010 6:52 PMPermanent Link

Bill Z

ZED Data Solutions

Tim

<<If the FillSchedQry a Firebird query component, or an ElevateDB query
component ?  If the former, then the alignment issue is on the Firebird
component end.>>

I am using a TSql query (in Lazarus) for the FillSchedQry and a TEDBTable for the FillSchedTbl. I have also tried to assign a date string to dNextFill (ie dNextFill := '22/4/2010') with the same result.  I am testing this on a mobile phone with Windows Mobile 6 Pro installed and all has been working well untill this problem.  The short date format on the mobile is dd/mm/yy......no option for a four digit year. Have also tried with the example above to use '22/4/10'.......no difference.

Bill Zwirs
Mon, Jun 7 2010 1:13 AMPermanent Link

Bill Z

ZED Data Solutions

Tim,

Have been able to solve my own problem by using an sql insert instead of the edit.....fieldbyname....post. No problems doing it that way. Although that did create my next problem when I tried to display the data in a data aware grid......again the same error when it comes to the date field. So I suppose that means it's probably a Lazarus problem

regards

Bill
Mon, Jun 7 2010 5:02 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

<< Have been able to solve my own problem by using an sql insert instead of
the edit.....fieldbyname....post. No problems doing it that way. Although
that did create my next problem when I tried to display the data in a data
aware grid......again the same error when it comes to the date field. So I
suppose that means it's probably a Lazarus problem >>

I'll see if I can replicate this and report it to the Lazarus developers.
The issue seems to be this:

procedure TDataSet.DataConvert(aField: TField; aSource, aDest: Pointer;
 aToNative: Boolean);

// There seems to be no WStrCopy defined, this is a copy of
// the generic StrCopy function, adapted for WideChar.
Function WStrCopy(Dest, Source:PWideChar): PWideChar;
var
  counter : SizeInt;
Begin
  counter := 0;
  while Source[counter] <> #0 do
  begin
    Dest[counter] := char(Source[counter]);
    Inc(counter);
  end;
  { terminate the string }
  Dest[counter] := #0;
  WStrCopy := Dest;
end;

var
 DT : TFieldType;

begin
 DT := aField.DataType;
 if aToNative then
   begin
   case DT of
>>>>>>>>>      // These ^ de-references here should be wrapped with an
>>>>>>>>> unaligned() call with an IFDEF WinCE block <<<<<<<<<<<<<<<<<
     ftDate, ftTime, ftDateTime: TDateTimeRec(aDest^) :=
DateTimeToDateTimeRec(DT, TDateTime(aSource^));
     ftTimeStamp               : TTimeStamp(aDest^) :=
TTimeStamp(aSource^);
     ftBCD                     : TBCD(aDest^) :=
CurrToBCD(Currency(aSource^));
     ftFMTBCD                  : TBcd(aDest^) := TBcd(aSource^);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 // See notes from mantis bug-report 8204 for more information
 //    ftBytes                   : ;
 //    ftVarBytes                : ;
     ftWideString              : WStrCopy(PWideChar(aDest),
PWideChar(aSource));
     end
   end
 else
   begin
   case DT of
>>>>>>>>>      // These ^ de-references here should be wrapped with an
>>>>>>>>> unaligned() call with an IFDEF WinCE block <<<<<<<<<<<<<<<<<
     ftDate, ftTime, ftDateTime: TDateTime(aDest^) :=
DateTimeRecToDateTime(DT, TDateTimeRec(aSource^));
     ftTimeStamp               : TTimeStamp(aDest^) :=
TTimeStamp(aSource^);
     ftBCD                     :
BCDToCurr(TBCD(aSource^),Currency(aDest^));
     ftFMTBCD                  : TBcd(aDest^) := TBcd(aSource^);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 //    ftBytes                   : ;
 //    ftVarBytes                : ;
     ftWideString              : WStrCopy(PWideChar(aDest),
PWideChar(aSource));
     end
   end
end;

--
Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jun 8 2010 9:10 PMPermanent Link

Bill Z

ZED Data Solutions

Tim,

>>I'll see if I can replicate this and report it to the Lazarus developers.
The issue seems to be this:<<

Thanks Tim.

regards

Bill
Wed, Jun 9 2010 1:57 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

Okay, it was a bug in FreePascal, and I submitted a bug report here:

http://bugs.freepascal.org/view.php?id=16681

Fortunately, I can actually fix this in our code by simply overriding the
DataConvert method and doing it correctly.  I will do so for the next EDB
build.   If you want something quick, shoot me a private email and I'll send
you a new build (fully-tested, of course).

--
Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jun 24 2010 4:48 AMPermanent Link

Kick

ENK Software

Tim,

I am having the same problem here, could you send me a new build for the lazarus (i am using B14 now) as well?

Greets,
Kick Martens
Thu, Jun 24 2010 5:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kick,

<< I am having the same problem here, could you send me a new build for the
lazarus (i am using B14 now) as well? >>

Actually, I'm preparing build 15 now, so if you can wait a few hours, you'll
have the complete build in your hands with both the SysErrorMessage fix and
the TDateTimeField fix. Smiley

Thanks,

--
Tim Young
Elevate Software
www.elevatesoft.com
Image