Recent

Author Topic: sqlite3 don't save date fields  (Read 1178 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 446
sqlite3 don't save date fields
« on: August 09, 2020, 12:49:11 am »
I having problems with sqlite3 saving fields date time, I define  as date the field but i insert fields not message error all look good but when i open table all date fields are empty, is first time that happen  to me, i try also insert with parameters all fields but still the same.... some ide what why that happen

  while not DBF1.EOF do begin
         SQLs.SQL.Text:='insert into lvacc (adate , adt , exc , auto, ckbit ) values(:pdate, :padt,:pexc , :pauto ,:pckbit )';
         SQLs.ParamByName('pdate').AsString:= FormatDateTime('yyyy/mm/dd', Dbf1.FieldByName('adate').AsDateTime );
         SQLs.ParamByName('padt').AsString := FormatDateTime('yyyy/mm/dd', Dbf1.FieldByName('adt').AsDateTime ) ;
         SQLs.ParamByName('pexc').AsString := Dbf1.FieldByName('exc').AsString;
         SQLs.ParamByName('pauto').AsString :=  Dbf1.FieldByName('auto').AsString ;
         SQLs.ParamByName('pckbit').AsString:= Dbf1.FieldByName('ckbit').AsString ;
         SQLs.ExecSQL;
         DBF1.Next;
      end;   

thanks.
Fernando 

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
Re: sqlite3 don't save date fields
« Reply #1 on: August 09, 2020, 10:51:57 am »
I don't see any ApplyUpdate and Commit statement.
Are you sure you commit your changes?
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

eldonfsr

  • Sr. Member
  • ****
  • Posts: 446
Re: sqlite3 don't save date fields
« Reply #2 on: August 09, 2020, 05:36:34 pm »
When return program call it, I doing the commit  all datas is update except de date fields only if change as text save the information as date field don't work....

I attach some image before and after changes...

thanks...

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: sqlite3 don't save date fields
« Reply #3 on: August 09, 2020, 05:55:01 pm »
Perhaps I am overlooking something but I do not seen any connection between the insert statement and the pictures. They seem to be two completely different tables ?

eldonfsr

  • Sr. Member
  • ****
  • Posts: 446
Re: sqlite3 don't save date fields
« Reply #4 on: August 23, 2020, 06:21:22 pm »
Sorry I make a mistake i put date like that '2020/08/20'  but sqlite wants like that '2020-08-20'  so i change format date and now going god thanks.

SDate := FormatDateTime('yyyy-mm-dd', now) this format the date to this way

thanks.

 

TinyPortal © 2005-2018