Gabriel Posted May 8, 2017 Share Posted May 8, 2017 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 Quote Link to comment Share on other sites More sharing options...
itognet Posted May 8, 2017 Share Posted May 8, 2017 UniMainModule.AdsQuery.Refresh; And remember UniDBGrid1.Columns[x].Editor = an uniedit field placed in a uniHiddenPanel. Quote Link to comment Share on other sites More sharing options...
Gabriel Posted May 8, 2017 Author Share Posted May 8, 2017 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. Quote Link to comment Share on other sites More sharing options...
itognet Posted May 8, 2017 Share Posted May 8, 2017 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 Quote Link to comment Share on other sites More sharing options...
Gabriel Posted May 8, 2017 Author Share Posted May 8, 2017 Here you go. I've only removed the connection properties. Thanks unGuiPrototipado3.rar Quote Link to comment Share on other sites More sharing options...
itognet Posted May 8, 2017 Share Posted May 8, 2017 At first glance it looks okey. I think I read somewhere that if you are using special characters as in baliña you have to handle that special when using params. Try doing a new select where without using params. Quote Link to comment Share on other sites More sharing options...
Gabriel Posted May 8, 2017 Author Share Posted May 8, 2017 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. Quote Link to comment Share on other sites More sharing options...
itognet Posted May 8, 2017 Share Posted May 8, 2017 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. Quote Link to comment Share on other sites More sharing options...
Gabriel Posted May 12, 2017 Author Share Posted May 12, 2017 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 12, 2017 Share Posted May 12, 2017 Hi, Also tried with FdConnection and FDQuery, same issue. ¿Does anyone have a working example with FDConnection? using Filters? Can you check it once again ?! Because it should work Best regards, Quote Link to comment Share on other sites More sharing options...
Gabriel Posted May 12, 2017 Author Share Posted May 12, 2017 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 Quote Link to comment Share on other sites More sharing options...
Ron Posted May 16, 2017 Share Posted May 16, 2017 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);beginif UniMainModule.AdsQuery.Active then begin UniMainModule.AdsQuery.Close; UniMainModule.ADsQuery.Params.ParamByName(Column.FieldName).Value := '%'+Value+'%'; UniMainModule.AdsQuery.Open; endend; 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. Quote Link to comment Share on other sites More sharing options...
Kattes Posted February 2, 2020 Share Posted February 2, 2020 You can also do simply the following: UniDBGrid1.DataSource.DataSet.Refresh; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.