Subject RE: [IBO] Using Filter and then FindFirst method causes exception
Author Helen Borrie
At 10:21 AM 16/03/2006, you wrote:
>Hi Helen! :)
>
> >
> > It looks as though you are trying to filter output from a
> > stored procedure. True or false?
>
>False
>
> >
> > Show
> >
> > 1. the exact SQL statement of the iboquery
>
>SELECT DISTINCT
> P.ProcedureID,
> P.Description,
> P.Code,
> C.Name,
> R.RoleDescription
>FROM
> ProcedureCode P
>INNER JOIN CATEGORY C ON (P.CATEGORYID = C.CATEGORYID)
>INNER JOIN ROLENAMES R ON (P.ROLEID = R.ROLEID)
>ORDER BY
> C.Name,
> P.Description
>
>
> > 2. the exact
> > entries used for the filter clause 3. the code used to apply
> > the filter
>
>procedure TfrmEditProcedure.edtSearchProcChange(Sender: TObject);
>begin
> dtsrcProcedure.DataSet.Filter := 'CODE = ''' + edtSearchProc.Text +'*''';
> dtsrcProcedure.DataSet.FindFirst;
>end;
>
>This is one example but it seems to not be working anywhere and it did work
>with the BDE.

Filtering with the BDE is working on the Paradox table that the BDE
writes to the user's hard disk. With non-BDE interfaces the
filtering mechanism adjusts the WHERE clause of the SELECT statement
and requeries the database. With the IBO scrolling dataset classes,
you have the added benefit of the multiple cursor buffers, which
allow the refresh to recycle the target rows in the buffer if they
are are within the current range resident in the buffer.

But filtering is a property of scrolling datasets, so referring to
the Dataset property of the datasource is not sufficient. You must
cast the dataset to a TIB_Bdataset class.


>Thanks for any suggestions,

procedure TfrmEditProcedure.edtSearchProcChange(Sender: TObject);
begin
with dtsrcProcedure.DataSet as TIB_Query do
// or, with TIB_Query(dtsrcProcedure.Dataset) do
begin
if Filtered then
begin
Filtered := False;
Filter := '';
end;
Filter := 'CODE = ''' + edtSearchProc.Text +'*''';
Filtered := True;
RefreshAction := raOpen;
Refresh;
end;
end;

Helen