Subject Re: [IBO] Query remembering previous search
Author Jason Wharton
Why are you clearing the SQL and also using a parameter?

Usually if you are using a parameter this means you have a fixed SQL
statement to remain prepared and used over and over again. Clearing the SQL
causes the statement to need to be prepared again.

Regards,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com

-- We may not have it all together --
-- But together we have it all --


----- Original Message -----
From: <correoschafa@...>
To: <IBObjects@yahoogroups.com>
Sent: Tuesday, February 18, 2003 10:18 AM
Subject: [IBO] Query remembering previous search


> Hi there,
>
> I have a simple form with a TIBOQuery, a TEdit and a 'Search'
> Tbutton. Here's the OnClick code:
>
> procedure TfmMain.Button1Click(Sender: TObject);
> begin
> with IBOQuery1 do
> try
> SQL.Clear;
> SQL.Add('SELECT CVEART FROM ARTICULOS WHERE CVEART=:pCve');
> Params[0].AsString:=Edit1.Text;
> Open;
> if IsEmpty then
> Showmessage('Item Not Found')
> else
> Showmessage('Item Found - ');
> finally
> Close;
> end;
> end;
>
> The first time I search for an item that is not in the database, and
> I get the 'Item not found' message. That is correct, but if next I
> search for an item that *is* in the database, I get the same 'Item
> not found' message. I think the Query is remembering the previous
> search, because the same happens if the first search is for a valid
> item (later I get 'Found' messages for invalid items.)
>
> I added 'Params.Clear' before and after 'SQL.Clear' but that does not
> help.
>
> Thanks in advance for your answers,
>
> -BQ