Problems with firebird and dbadvgrid timestamp fields

Hi, I'm having trouble editing TIMESTAMP fields that store times in the DBAdvGrid.

The database is firebird.

With field.DisplayFormat = 'HH:mm', field.EditMask = !90:00;1;_ and column.editor = edTimeEdit, when I go to edit the field, it assigns the current time instead of allowing me to edit the time that there is (for example, if the cell contains 23:18 and it is 09:17, when entering to edit the cell - the value of the editor - it goes to 09:17). I have tried modifying the value of the Grid.DateTimePicker.Time (and Text, and Date) in the Grid.BeforeEdit event, but it has no effect.

I have tried every possible combination of Field.EditMask, Field. DisplayFormat, Grid.Column.editor and Grid.Column.Mask and each gives a different problem (date appears, resets minutes to :00, etc., etc.).

Is there a known bug in this case or a way to make it possible to edit the masked time without error?

Or how could I make the Grid.DateTimePicker preserve the time for editing?

Is FormatSettings.TimeSeparator = ':' on your system?

Yes.

I have found a solution to the fact that the Grid.DateTimePicker puts the current time instead of the stored time.

procedure TForm1.FormCreate(Sender: TObject);
begin
...
DBAdvGrid1.DateTimePicker.OnEnter:=MiGridDateTimePickerEnter;
end;

procedure TForm1.MiGridDateTimePickerEnter(Sender: TObject);
begin
DBAdvGrid1.DateTimePicker.DateTime:=strtotime(DBAdvGrid1.Cells[DBAdvGrid1.Col,DBAdvGrid1.Row]);
Memo1.Lines.Add(DBAdvGrid1.DateTimePicker.Text);
end;

It remains strange you need to do this. If the time is in system format in the cell, this should go automatic.

1 Like

Yes it's weird.

When I go to edit the cell with the time, if I'm in Debug mode, it gives me this error:

Project Project1.exe raised exception class EConvertError with message ''30/12/1899 9:58:00' is not a valid time'.

Then let edit.

When breaking the execution the error is in System.SysUtils:

function StrToTime(const S: string;
const AFormatSettings: TFormatSettings): TDateTime;
begin
if not TryStrToTime(S, Result, AFormatSettings) then
--> ConvertErrorFmt(@System.SysConst.SInvalidTime, [S]);
end;

I don't know if it has to do with it.

Make sure your DB field returns only time as text and with the same time separator as the operating system time separator, i.e. normally something like: '9:58:00'

Nothing, it doesn't work well, if I fix one thing another breaks.
Now I have discovered that doing post with dbnavigator loses the edited value and returns to the original... :(

I'm going to try to reinstall everything (Delphi included).

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.