Lazarus

Programming => Databases => Topic started by: pcurtis on April 19, 2021, 03:20:26 pm

Title: [CLOSED] ZEOS Change query text at runtime
Post by: pcurtis on April 19, 2021, 03:20:26 pm
How can I change query text at run time of design time created objects. With run time created objects I do this

Code: Pascal  [Select][+][-]
  1.   MyQuery := TZQuery.Create(Self);
  2.  
  3.   sSQL := ' SELECT ...';
  4.  
  5.   MyQuery.SQL.Clear;
  6.   MyQuery.SQL.Add(sSQL);
  7.  

but with the design time object it does not work.
Title: Re: ZEOS Change query text at runtime
Post by: zeljko on April 19, 2021, 03:43:44 pm
sSQL := 'SELECT ....';
MyDesignSQL.Clear;
MyDesignSQL.Add(sSQL);
Title: Re: ZEOS Change query text at runtime
Post by: pcurtis on April 19, 2021, 03:49:35 pm
Read the question. It doesn't work.
Title: Re: ZEOS Change query text at runtime
Post by: dseligo on April 19, 2021, 04:07:25 pm
What do you mean it doesn't work? Do you have an error?

What does ShowMessage(MyDesignSQL.SQL.Text); show?
Title: Re: ZEOS Change query text at runtime
Post by: pcurtis on April 19, 2021, 04:13:25 pm
Nothing, just empty. No errors, just the string is never changed.
Title: Re: ZEOS Change query text at runtime
Post by: af0815 on April 19, 2021, 04:22:10 pm
Before you change the SQL, is your Query deaktivated ?

MyQuery.active:= false;

you cannot change the sql on a active query.
Title: Re: ZEOS Change query text at runtime
Post by: miab3 on April 19, 2021, 04:28:42 pm
Hi,

ZQuery1.Close;
ZQuery1.SQL.Text:='...';

MichaƂ
Title: Re: ZEOS Change query text at runtime
Post by: pcurtis on April 19, 2021, 04:32:41 pm
No, it's closed.
Title: Re: ZEOS Change query text at runtime
Post by: balazsszekely on April 19, 2021, 04:37:14 pm
@pcurtis
Do you open the query after you change the sql?  :)
Title: Re: ZEOS Change query text at runtime
Post by: pcurtis on April 19, 2021, 04:42:29 pm
OK. Just reinstalled  ZEOS and all is OK.
Title: Re: ZEOS Change query text at runtime
Post by: dseligo on April 19, 2021, 06:13:52 pm
Before you change the SQL, is your Query deaktivated ?

MyQuery.active:= false;

you cannot change the sql on a active query.

In ZEOS you can. It's automatically closed when you change SQL.Text
Title: Re: [REOPENED] ZEOS Change query text at runtime
Post by: pcurtis on April 20, 2021, 06:21:56 am
Thats what I thought, but now another problem occurs wiih parameters.

ZQuery complains that it cant find a parameter even if it is in the query. (The same code works fine in runtime  created objects.
Title: Re: [REOPENED] ZEOS Change query text at runtime
Post by: balazsszekely on April 20, 2021, 06:36:57 am
@pcurtis
Quote
Thats what I thought, but now another problem occurs wiih parameters.

ZQuery complains that it cant find a parameter even if it is in the query. (The same code works fine in runtime  created objects.
A small demo please, otherwise we just shot in the dark.
Title: Re: [REOPENED] ZEOS Change query text at runtime
Post by: pcurtis on April 20, 2021, 12:43:15 pm
It's a little more complicated. I'm working on a demo, but first I want to try Laz 2.0.10
Title: Re: [REOPENED] ZEOS Change query text at runtime
Post by: pcurtis on April 21, 2021, 09:34:08 pm
It's beginning to look like a 2.0.12 issue or compatibly problem. It works as expected in 2.0.10 and is faster.

Yep Laz 2.0.12 + ZEOS 7.2.8 sucks
TinyPortal © 2005-2018