Lazarus

Programming => Databases => Topic started by: greaseflog on December 06, 2019, 02:52:08 pm

Title: ZQuery
Post by: greaseflog on December 06, 2019, 02:52:08 pm
How can i get the value from SQL.Text when the program is running? I want the value from  file.dfm.

My problem is:
    I have the zquery component  what I use with the zquery with simples query, but I want execute sometime with diferents condicions, with diferents filds. 

Thanks for all.
Title: Re: ZQuery
Post by: fjabouley on December 07, 2019, 08:30:02 pm
Hello !
I'm not sure I correctly understand what you want to do ?
If you want to retrieve the SQL text, just do (yourZquery).SQL.Text ?
If you want to do some other stuff, you can create Zquery at runtime :


Code: Pascal  [Select]
  1. var query:TZquery;
  2. begin
  3. query := TZquery.Create(nil);
  4. with query do begin
  5. connection := (your TZConnection);
  6. SQL.Clear;
  7. SQL.Add('SELECT BLABLABLA.....');
  8. (eventually ParambyName('your parameter').AsString := ....)
  9.  
  10.  
  11. ExecSQL;
  12.  
  13.  
  14. or
  15.  
  16.  
  17. Open;
  18. while not EOF do begin
  19. (work with FieldbyName('...').Asstring);
  20. Next;
  21. end;
  22. Close;
  23.  
  24.  
  25. Free;
  26. end;
  27.  
  28.  
  29.  


Regards
Title: Re: ZQuery
Post by: mangakissa on December 09, 2019, 07:43:51 am
please give some code to tell us what you've done