Board index » delphi » Index Search

Index Search

Hi Group!
I have an idea, but i don't know how to solve the problem.That's why I am
writing to you falks.
I am using IBDatabase. TIBTable has a lot of records. I would like to create
something similar to Index Search in help files where I will write letters
in TEdit box, and TIBQuery will return every time less and less records. Can
anybody give me an idea how to create such a TIBQuery or how to filter
TIBTable.

Best Regards

Bojan Huljev

--
bojan.hul...@inet.hr

 

Re:Index Search


Quote
Bojan Huljev wrote:
> I am using IBDatabase. TIBTable has a lot of records. I would like to create
> something similar to Index Search in help files where I will write letters
> in TEdit box, and TIBQuery will return every time less and less records. Can
> anybody give me an idea how to create such a TIBQuery or how to filter
> TIBTable.

First, it is not a good idea to use Table components with IB or any other C/S
database.  For best performance, use Queries.

How to implement 'incremental search' depends on the component set
(BDE/IBX/IBO/...) you're using.  I've done this with the IBO components, but not
with any of the other ones.

Regards,
Aage J.

Re:Index Search


Hi Aage!

Thank you for response. Can you give me idea or any tip how you did it with
IBO components.
Thank you in advance!

Bojan Huljev

Quote
"Aage Johansen" <aage.johan...@kreftreg.no> wrote in message

news:3CC7BFD4.46F6EA20@kreftreg.no...
Quote

> First, it is not a good idea to use Table components with IB or any other
C/S
> database.  For best performance, use Queries.

> How to implement 'incremental search' depends on the component set
> (BDE/IBX/IBO/...) you're using.  I've done this with the IBO components,
but not
> with any of the other ones.

> Regards,
> Aage J.

Re:Index Search


Quote
> Hi Group!
> I have an idea, but i don't know how to solve the problem.That's why I am
> writing to you falks.
> I am using IBDatabase. TIBTable has a lot of records. I would like to
create
> something similar to Index Search in help files where I will write letters
> in TEdit box, and TIBQuery will return every time less and less records.
Can
> anybody give me an idea how to create such a TIBQuery or how to filter
> TIBTable.

I'll try to show you  the way how to do in the following code,. and with
only one field....

IBQuery1.SQL.Text = 'SELECT Id, Name, Address FROM clients';
IBQuery.Filtered = TRUE;

and OnChange event handler for a TEdit component:

TForm1.OnEdit1Change(Sender: TObject);
begin
 try
  IBQuery.DisableControls();
  IBQuery1.Filter := 'Name LIKE '''+TEdit(Sender).Text+'''';
 finally
  IBQuery.EnableControls();
 end;
end;

It will work with TTable components too... It is enough slow way but could
be used.

In addition... The better idea is to consider to use TIBQuery components if
you work under a client-server project....
In this case another way and better one... to use WHERE clause in query
statements.
I mean something like "SELECT foo FROM bar WHERE Name LIKE
"%filter_string%"... this will increase speed because in this case all the
necessary calculations performs sql server and amount of data which is
pumping through a network has a less worth.

Best regards.
 Evgeny V. Levashov

Re:Index Search


Quote
Bojan Huljev wrote:
> Thank you for response. Can you give me idea or any tip how you did it with
> IBO components.

If you use IBO, I think you will find that a sample of this is provided.
Very little programming is involved to make it work, you mostly set some
properties.  It may seem somewhat tricky the first time before you have it
working.  There is a newsgroup for IBO users (which you can find through
www.ibobjects.com).

Regards,
Aage J.

Re:Index Search


Thank you Evgeny!

I solve the problem. Here you are the code:

procedure TfmForm1.edEdit1(Sender: TObject);
begin
  with dmDataModule1.IBQuery1 do begin
    Close;
    SQL.Text := 'SELECT * FROM Table1 WHERE Upper(Field1) LIKE "'+
AnsiUpperCase(edCrewSearch.Text) + '%"';
    Open;
  end
end;

--
Best Regards, Bojan Huljev
E-Mail: bojan.hul...@inet.hr

"Evgeny V. Levashov" <eug...@mebelmassiv.tula.ru> wrote in message
news:444992605@mebelmassiv.tula.ru...

Quote
> > Hi Group!
> > I have an idea, but i don't know how to solve the problem.That's why I
am
> > writing to you falks.
> > I am using IBDatabase. TIBTable has a lot of records. I would like to
> create
> > something similar to Index Search in help files where I will write
letters
> > in TEdit box, and TIBQuery will return every time less and less records.
> Can
> > anybody give me an idea how to create such a TIBQuery or how to filter
> > TIBTable.

> I'll try to show you  the way how to do in the following code,. and with
> only one field....

> IBQuery1.SQL.Text = 'SELECT Id, Name, Address FROM clients';
> IBQuery.Filtered = TRUE;

> and OnChange event handler for a TEdit component:

> TForm1.OnEdit1Change(Sender: TObject);
> begin
>  try
>   IBQuery.DisableControls();
>   IBQuery1.Filter := 'Name LIKE '''+TEdit(Sender).Text+'''';
>  finally
>   IBQuery.EnableControls();
>  end;
> end;

> It will work with TTable components too... It is enough slow way but could
> be used.

> In addition... The better idea is to consider to use TIBQuery components
if
> you work under a client-server project....
> In this case another way and better one... to use WHERE clause in query
> statements.
> I mean something like "SELECT foo FROM bar WHERE Name LIKE
> "%filter_string%"... this will increase speed because in this case all the
> necessary calculations performs sql server and amount of data which is
> pumping through a network has a less worth.

> Best regards.
>  Evgeny V. Levashov

Other Threads