incorrect datefields in lazarus with fibl lazarus / 16-Databases ---------------------------------------------------------------------- strikeeagle · 2006-12-05 19:16 Hi all, As a newbie on Linux/Lazarus i am testing database connectivity with lazarus. Until now this has been very dissapointing. I'm using lazarus 09.20 ans Firebird 2.0. With the component FIBL i tried to create a database application but the datefields will not show the proper dates. In the dbgrid the date fields are show as '00-00-0000' both under Windows XP as under Linux. Has anyone got any suggestions of how to solve this ? Thanx in advance ! Pieter. ---------------------------------------------------------------------- C#R# · 2006-12-07 18:34 Hi, I have the same problem, and it´s began when the 9.20 was installed. I see the update in the DB with the IBEASY and it´s stored ok ! The problem is when the date is retrieved by dataset / datasource.... If enybody can help ..... Thanks. ---------------------------------------------------------------------- Vincent Snijders · 2006-12-07 19:51 I asked on the #fpc channel on IRC. I got this answer. QuoteThe format of Datefield changed between 2.0.2 and 2.0.4. Now it's Delphi compatible. But it could be that the FIBL people made FILBL compatible with the fpc-format of version 2.0.2. So now it breaks... So probably the FIBL-people can easily fix this. Or you can look for some ifdef fpc's theirselves ---------------------------------------------------------------------- strikeeagle · 2006-12-09 14:44 Vincent, Looking at the site of FIBL at sourceforge makes me believe that a quick bugfix will not be very likely. The last version dates back to 23-8-2005. Trying with IFDEF FPC sounds nice, but I haven't got a clue howto... Any suggestions ?? Pieter. ---------------------------------------------------------------------- Tukapinky · 2007-04-11 10:56 Hello, first to request excuses because I do not dominate the English and I have translated the text with the translator of Google. I have had he himself problem. I have been studying the changes and have obtained that it works. For it it is necessary to modify the unit “FIBDataSet.pas” of “FIBL”. As or it has been said before the problem takes place because in version 2.0.4 of the FPC the format of the fields is modified that store to dates or hours. In FIBDataSet.pas one always works with TDateTime whereas in the FPC depends on if the field is a TDate, TTime or TDateTime. The modification of the FPC that affects to us finds in “lazarus \ fpc \ 2.0.4 \ source \ fcl \ db \ dataset.inc” and affects the functions SetFieldData and GetFieldData. In them, in case the field is type ftDate, ftTime or ftDateTime makes a conversion to TDateTimeRec that causes the error in “FIBL” library (See lines 519 and 590 of dataset.inc). In order to solve it that conversion must undo in “FIBDataSet.pas” (the new thing is enclosed between //***************************************): LINE 1989: Code: [Select]function TFIBCustomDataSet.GetFieldData(Field: TField; Buffer: Pointer): Boolean; var   Buff, Data: PChar;   CurrRecord: PRecordData; begin   result := False;   Buff := GetActiveBuf;   if (Buff = nil) or (not IsVisible(Buff)) then exit;   (* The intention here is to stuff the buffer with the data for the *)   (* referenced field for the current record.                        *)   CurrRecord := PRecordData(Buff);   if (Field.FieldNo > 0) and      (Field.FieldNo <= CurrRecord^.rdFieldCount) then begin     if (not IsVisible(Buff)) then begin     end else begin       result := not CurrRecord^.rdFields[Field.FieldNo].fdIsNull;       if result and (Buffer <> nil) then         with CurrRecord^.rdFields[Field.FieldNo] do begin           Data := Buff + CurrRecord^.rdFields[Field.FieldNo].fdDataOfs;           if (fdDataType = SQL_VARYING) or (fdDataType = SQL_TEXT) then begin             Move(Data^, Buffer^, fdDataLength);             PChar(Buffer)[fdDataLength] := #0;           end          //***************************************           else if (Field.DataType in [ftDate, ftTime, ftDateTime]) then             TDateTimeRec(buffer^) := DateTimeToDateTimeRec(Field.DataType, TDateTime(pointer(Data)^))          //***************************************           else             Move(Data^, Buffer^, Field.DataSize);         end;     end   end else if (Field.FieldNo < 0) then begin     Inc(Buff, FRecordSize + Field.Offset);     result := Boolean(Buff[0]);     if result and (Buffer <> nil) then       Move(Buff[1], Buffer^, Field.DataSize);   end; end; LINE 2587: Code: [Select]procedure TFIBCustomDataSet.SetFieldData(Field: TField; Buffer: Pointer); var   Buff, TmpBuff: PChar; begin   (* Cannot update a record without a FQUpdate query existing. *)   Buff := GetActiveBuf;   if Field.FieldNo < 0 then begin     TmpBuff := Buff + FRecordSize + Field.Offset;     Boolean(TmpBuff[0]) := LongBool(Buffer);     if Boolean(TmpBuff[0]) then       Move(Buffer^, TmpBuff[1], Field.DataSize);     WriteRecordCache(PRecordData(Buff)^.rdRecordNumber, Buff);   end else begin     CheckEditState;     with PRecordData(Buff)^ do begin       (* If inserting, make sure certain settings are established. *)       CheckInsertMode(Buff);       if (Field.FieldNo > 0) and (Field.FieldNo <= rdFieldCount) then begin         Field.Validate(Buffer);         if (Buffer = nil) or            (Field is TFIBStringField) and (PChar(Buffer)[0] = #0) then           rdFields[Field.FieldNo].fdIsNull := True         else begin           //***************************************           if (Field.DataType in [ftDate, ftTime, ftDateTime]) then             TDateTime(buffer^) := DateTimeRecToDateTime(Field.DataType, TDateTimeRec(buffer^));           //***************************************           Move(Buffer^, Buff[rdFields[Field.FieldNo].fdDataOfs],                  rdFields[Field.FieldNo].fdDataSize);           if (rdFields[Field.FieldNo].fdDataType = SQL_TEXT) or              (rdFields[Field.FieldNo].fdDataType = SQL_VARYING) then             rdFields[Field.FieldNo].fdDataLength := StrLen(PChar(Buffer));           rdFields[Field.FieldNo].fdIsNull := False;           if rdUpdateStatus = usUnmodified then begin             if State = dsInsert then               rdUpdateStatus := usInserted             else               rdUpdateStatus := usModified;           end;           WriteRecordCache(rdRecordNumber, Buff);           SetModified(True);         end;       end;     end;   end;   if not (State in [dsCalcFields, dsFilter, dsNewValue]) then     DataEvent(deFieldChange, Longint(Field)); end; I hope that this solves your problem. Greetings. ---------------------------------------------------------------------- C#R# · 2007-04-12 14:39 Hi TukaPinky It realy work wery well !!! Thank you !!!!   http://www.yonkis.com/mediaflash/1000000.swf