Recent

Author Topic: Update doesn't work and break sqlite connexion...  (Read 9956 times)

nadop

  • New Member
  • *
  • Posts: 12
Re: Update doesn't work and break sqlite connexion...
« Reply #15 on: March 31, 2016, 03:06:02 pm »
Also you can set properties

In SQLQuery
Options.sqoAutoApplyUpdate in True

In SQLTransaction
Action in caCommit

And set property you DataSource
AutoEdit in True

And comment EnregistrerLesChangements in Quitter.

gelinp

  • Full Member
  • ***
  • Posts: 114
Re: Update doesn't work and break sqlite connexion...
« Reply #16 on: April 02, 2016, 07:01:43 am »
I reply to myself, I succedeed to correct my code and data parameters.

I attached screen casts of data parameters for components Connexion, Transaction, SQLs and DataSource. And also source code and .lfm of main  form.


What was wrong ? Some parameters like :

  • TSQLQuery : sqoAutoApplyUpdates and sqoAutoCommit (not activated was wrong). Also AutoCalcFields (not activated was wrong). UpdateMethode = upWhereKeyOnly
  • TDataSource : AutoEdit (not activated was wrong)
  • Transaction : Action could be caNone because I read in wiki that it is not used... But I need to activate Option stoUseImplicit.

In main source code I added a procedure to connect dynamically. Finally I Idded log events, it display UPDATE SQLquery and it's fine. Look for main.pas file into zip file to read all code... :
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.DynamicConnect;
  2. var
  3.   dir : shortstring;
  4. begin
  5.   // Retrouve le dossier courrant (0 indique le dossier courant)
  6.   getdir(0,dir);
  7.  
  8.   // bibliothèque Sqlite...
  9.   {$IFDEF Windows}
  10.   SQLiteDefaultLibrary:= dir + '\sqlite3.dll';
  11.   {$ELSE}
  12.   SQLiteDefaultLibrary:='/usr/lib/libsqlite3.so';
  13.   {$ENDIF}
  14.  
  15.   // Connect
  16.   SQLMasterSequences.Close;
  17.   SQLDetailSeances.Close;
  18.  
  19.   if not SQLite3Connection1.Connected then
  20.   begin
  21.        {$IFDEF Windows}
  22.        SQLite3Connection1.DatabaseName:=dir + '\data.sqlite';
  23.        {$ELSE}
  24.        SQLite3Connection1.DatabaseName:=dir + '/data.sqlite';
  25.        {$ENDIF}
  26.   end;
  27.  
  28.   SQLite3Connection1.Connected := true;
  29.   SQLTransaction1.Active := true;
  30.   SQLMasterSequences.Open;
  31.   SQLDetailSeances.Open;
  32.  
  33.   // We do need to tell our TSQLConnection what to log:
  34.   SQLite3Connection1.LogEvents:=LogAllEvents; //= [detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack]
  35.   // ... and to which procedure the connection should send the events:
  36.   SQLite3Connection1.OnLog:=@Self.GetLogEvent;
  37. end;    

Thank you very much for your help ! Thank you again to helped me :-)
« Last Edit: April 02, 2016, 07:15:48 am by gelinp »
My configuration is : Lazarus 1.6+dfsg-1 / FPC 3.0.0 / Debian Mint / x86_64-linux-gtk2

 

TinyPortal © 2005-2018