Jump to content

Refresh UniDbGrid


Gabriel

Recommended Posts

Hi, 

 

I'm using an AdsQuery to populate a data from and Advantage Database, wich works great. But I'm Having problem filtering the data (I'm trying to make the same thing as the GridFilter example, but with an AdsQuery).

 

I Just can't refresh the query.

 

This is my code on the UniDbGridColumnFilter event

procedure TMainForm.UniDBGrid1ColumnFilter(Sender: TUniDBGrid;
  const Column: TUniDBGridColumn; const Value: Variant);
begin
if UniMainModule.AdsQuery.Active then
  begin
    UniMainModule.ADsQuery.Params.ParamByName(Column.FieldName).Value := '%'+Value+'%';

    UniMainModule.AdsQuery.Open;
  end
end;

I also try Closing, and Opening the Query, Refreshing it. But nothing seems to work.

 

 

Regards

 

Gabriel

 

Link to comment
Share on other sites

UniMainModule.AdsQuery.Refresh;

 

And remember UniDBGrid1.Columns[x].Editor = an uniedit field placed in a uniHiddenPanel.

 

As i said, I also try Closing, and Opening the Query, Refreshing it. But nothing seems to work.

Link to comment
Share on other sites

I remember I had problems with the filtering too. I analyzed the Filter demo serveral times until I understood how it worked.

Can you show/send the project?

 

Btw, with you use % + % then I assume that you have used LIKE in the select statement ;)

Link to comment
Share on other sites

If I use

UniMainModule.AdsQuery.SQL.Clear;
UniMainModule.AdsQuery.SQL.Add('Select * from elPersonas where Empleado <=500');
UniMainModule.AdsQuery.Open;

The query is executed and the DbGrid updated, almost instantly. So the issue must be with the params definition.

Link to comment
Share on other sites

Be sure that you have setup your SQLDialect, and CharacerSet exacty like on the Ads server installation.

And be sure to have only one gds32.dll file and equal the server version. Best to have it in same dir as your application.

 

You can also try with a FDConnection and a FDQuery, they can talk Ads too natively.

Link to comment
Share on other sites

I've tried everythig, and still can't refresh the data grid.

 

the only thing that works was closing the connection, and then open it again, like this:

procedure TMainForm.UniDBGrid1ColumnFilter(Sender: TUniDBGrid;
  const Column: TUniDBGridColumn; const Value: Variant);
begin
if UniMainModule.AdsQuery.Active then
  begin
    UniMainModule.ADsQuery.Params.ParamByName(Column.FieldName).Value := '%'+Value+'%';
    UniMainModule.AdsConnection1.Disconnect;
    UniMainModule.AdsQuery.Open;
  end
end;

So, basically, the problem is with the connection.

 

Also tried with FdConnection and FDQuery, same issue.

 

¿Does anyone have a working example with FDConnection? using Filters?

 

 

Regards

Link to comment
Share on other sites

Hi,

 

 

Can you check it once again ?!

Because it should work

 

Best regards,

 

 

I will.

 

¿I have to specify anything special in the conection? ¿Could you see the code that I upload?

 

FDQuery does not have the method ADOQuery1.Requery;, as used on the example. I have to use either TAdsConnection or FDConnection

 

Please. Help!

 

Regards

Link to comment
Share on other sites

Did you try to close the query before changing params and opening again?

 

Like this:

 

procedure TMainForm.UniDBGrid1ColumnFilter(Sender: TUniDBGrid;
  const Column: TUniDBGridColumn; const Value: Variant);
begin
if UniMainModule.AdsQuery.Active then
  begin

    UniMainModule.AdsQuery.Close;
    UniMainModule.ADsQuery.Params.ParamByName(Column.FieldName).Value := '%'+Value+'%';

    UniMainModule.AdsQuery.Open;
  end
end;

 

This is how I have to do it with MySQLDac components, as refresh will

not change the sql or params already loaded as the query was opened,

but only retrieve new data from the db on the existing query setup.

Link to comment
Share on other sites

  • 2 years later...

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...