Jump to content

Filtering in UniDBGrid using FDQuery


artem_niko

Recommended Posts

Hello!

I'm trying filtering record in UniDBGrid, as in demo ...\Framework\uniGUI\Demos\Desktop\GridFiltering

But, I'm using FireDAC, not ADO.

This is my code in UniDBGrid:

procedure TUniFrameG0.UniDBGrid1ColumnFilter(
  Sender: TUniDBGrid; const Column: TUniDBGridColumn; const Value: Variant);
begin
  if FDQuery1.Active then
  begin
    FDQuery1.Close;
    FDQuery1.Params.ParamByName(Column.FieldName).Value := '%' + Value + '%';
    FDQuery1.Open;
  end;
end;

And created param in FDQuery:

image.png.510995cb185a2e607fc232c39a5b92f6.png

But, this is not working and I get error:

FDQuery1: Parameter 'OV_08' not found.

 

How right using FDQuery for filtering records, as ADOQuery from demo?

Link to comment
Share on other sites

2 hours ago, Oliver Morsch said:

Can you Show your SQL query?

I'm using stored procedure for select records from database:

procedure TUniFrameG0.UniDBGrid1ColumnFilter(Sender: TUniDBGrid; const Column: TUniDBGridColumn; const Value: Variant);
begin
  if FDConnection1.Connected = True then
  begin
    FDQuery1.Close;
    FDQuery1.SQL.Clear;
    FDQuery1.SQL.Text:='SELECT * FROM Procedure04';
    FDQuery1.Params.ParamByName(Column.FieldName).Value := '%' + Value + '%';
    FDQuery1.Open;
  end;
end;

I'm not use SQL property FDQuery from design, only runtime...

 

How this using stored procedure in FDQuery, as in demo?

Link to comment
Share on other sites

4 minutes ago, Oliver Morsch said:

I have not much experience with stored procedures, but normally - when using parameters - in SQL there should be the used parameter declared:

select * from procedure04 where MyFieldName = :MyFieldName

Whell...I'm using stored procedures...

4 minutes ago, Oliver Morsch said:

select * from procedure04 where MyFieldName = :MyFieldName

One query for all parameters?

... where MyFieldName=:MyFieldName, MyFieldName2=:MyFieldName2...?

Link to comment
Share on other sites

23 minutes ago, Sherzod said:

Basically I use this property (Filter).

It turns out that if I create a personal parameter for each field and write in the FDQuery.Filter property something like (Field1 like %:Param1%) and (Field2 like %:Param2%)... then it will work with the property FDQuery.Filtered=True and calling my stored procedure that calls a SELECT query?

Link to comment
Share on other sites

18 hours ago, artem_niko said:

It turns out that if I create a personal parameter for each field and write in the FDQuery.Filter property something like (Field1 like %:Param1%) and (Field2 like %:Param2%)... then it will work with the property FDQuery.Filtered=True and calling my stored procedure that calls a SELECT query?

 

Hello,

Can you try :

http://forums.unigui.com/index.php?/topic/18946-how-to-use-unicombobox-in-unidbgrid/&do=findComment&comment=107950

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...