Recent

Author Topic: [SOLVED} SQLite Zeos Update  (Read 4531 times)

Pe3s

  • Hero Member
  • *****
  • Posts: 596
Re: SQLite Zeos Update
« Reply #15 on: April 28, 2022, 02:26:18 pm »
@zvoni The select code will reload the database but will not select the edited line

Zvoni

  • Hero Member
  • *****
  • Posts: 2897
Re: SQLite Zeos Update
« Reply #16 on: April 28, 2022, 02:51:10 pm »
@zvoni The select code will reload the database but will not select the edited line
And you didn't read the posts.
I'm talking about your general SQL-Statement.
Don't use SELECT * FROM

Everything else like in your Post 8 should still work

And in Post 10 i told you how to autoselect the changed Row, even if the Grid gets reloaded
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Pe3s

  • Hero Member
  • *****
  • Posts: 596
Re: SQLite Zeos Update
« Reply #17 on: April 28, 2022, 04:35:51 pm »
@Zvoni It seems easy to remember the id, update the database, reload the database and restore the remembered id. Only with the implementation is worse, lack of knowledge.But there are willingness to learn.
« Last Edit: April 29, 2022, 09:33:27 am by Pe3s »

Zvoni

  • Hero Member
  • *****
  • Posts: 2897
Re: SQLite Zeos Update
« Reply #18 on: April 29, 2022, 09:58:20 am »
Aircode
Code: Pascal  [Select][+][-]
  1. Var MyID:Integer;
  2. //Later
  3. ZQuery1.SQL.Text:='SELECT ID, Opis, Link, Kategoria, E-Mail FROM base';
  4. //Load Result into DBGrid
  5.  
  6. // Later
  7. MyID:=ZQuery1.FieldByName('ID').AsInteger;
  8. ZQuery1.Edit;
  9.   ZQuery1.FieldByName('Opis').AsString := LabeledEdit1.Text;
  10.   ZQuery1.FieldByName('Kategoria').AsString := LabeledEdit2.Text;
  11.   ZQuery1.FieldByName('E-Mail').AsString := LabeledEdit3.Text;
  12.   ZQuery1.Post;
  13.   ZQuery1.ApplyUpdates;
  14.   MessageDlg('Informacja','Zapisano zmiany!', mtinformation, [mbOK], 0);
  15. //Now if you reload
  16. DBGrid1.DataSource.Dataset.Refresh;
  17. DBGrid1.DataSource.Dataset.Locate('ID',MyID,[loCaseInsensitive]);
  18.  
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

miab3

  • Full Member
  • ***
  • Posts: 145
Re: SQLite Zeos Update
« Reply #19 on: April 29, 2022, 01:37:23 pm »
In the case of ZEOS, it is enough to:

Code: Pascal  [Select][+][-]
  1. ZQuery1.SQL.Text:='SELECT ID, Opis, Link, Kategoria, E-Mail FROM base'; // or 'select * from base'
  2. ZQuery1.Open;
  3. ...
  4. ZQuery1.Edit;
  5. ZQuery1.FieldByName('Opis').AsString := LabeledEdit1.Text;
  6. ZQuery1.FieldByName('Kategoria').AsString := LabeledEdit2.Text;
  7. ZQuery1.FieldByName('E-Mail').AsString := LabeledEdit3.Text;
  8. ZQuery1.Post;
  9. MessageDlg('Informacja','Zapisano zmiany!', mtinformation, [mbOK], 0);

Michał
« Last Edit: April 29, 2022, 01:46:47 pm by miab3 »

Zvoni

  • Hero Member
  • *****
  • Posts: 2897
Re: SQLite Zeos Update
« Reply #20 on: April 29, 2022, 01:42:57 pm »
Code: Pascal  [Select][+][-]
  1.  // or 'select * from base'
  2.  
DON'T!
Period!
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

miab3

  • Full Member
  • ***
  • Posts: 145
Re: SQLite Zeos Update
« Reply #21 on: April 29, 2022, 01:52:17 pm »
What now?:
Code: Pascal  [Select][+][-]
  1. ZQuery1.SQL.Text:='SELECT ID, Opis, Link, Kategoria, E-Mail FROM base'; // or 'select * from base'
  2. ZQuery1.Open;
  3. ...
  4. ZQuery1.Edit;
  5. ZQuery1.FieldByName('Opis').AsString := LabeledEdit1.Text;
  6. ZQuery1.FieldByName('Kategoria').AsString := LabeledEdit2.Text;
  7. ZQuery1.FieldByName('E-Mail').AsString := LabeledEdit3.Text;
  8. ZQuery1.Post;
  9. MessageDlg('Informacja','Zapisano zmiany!', mtinformation, [mbOK], 0);
  10. ...
  11. ZQuery1.Edit;
  12. ZQuery1.FieldByName('tel').AsString := LabeledEdit4.Text;
  13. ZQuery1.Post;
  14. ???
Michał

Zvoni

  • Hero Member
  • *****
  • Posts: 2897
Re: SQLite Zeos Update
« Reply #22 on: April 29, 2022, 02:15:42 pm »
What now?:
Code: Pascal  [Select][+][-]
  1.  // or 'select * from base'
  2.  
Michał
Don't advise/teach people to use "SELECT * FROM" in Production-Code
It's a ticking time-bomb
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Pe3s

  • Hero Member
  • *****
  • Posts: 596
Re: SQLite Zeos Update
« Reply #23 on: April 29, 2022, 05:00:04 pm »
 Thank you very much for your help. Have a nice day. Greetings

 

TinyPortal © 2005-2018