Refresh data from UniQuery

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kneighbour
Posts: 77
Joined: Wed 08 Oct 2008 04:55

Refresh data from UniQuery

Post by kneighbour » Tue 12 May 2020 07:52

I am having problems refreshing data. I have a UniQuery on a form that returns a series of records. Let us say something like

"SELECT ID, CUSTOMERNAME, CREDITLIMIT FROM CUSTOMERS WHERE ID=10"

I put a couple of DB edit boxes on a form and link them to each field in this query. No worries. I can edit save, delete, etc.

But now let us do something (on the same form perhaps) that will update the table CUSTOMERS. Something like

"UPDATE CUSTOMERS SET CREDITLIMIT=0 WHERE ID=10".

Ok. Now we have updated the data that the original UniQuery is pointing to. I can see no way to get this original query to update with the new values that are now in the table. You would think that something like UniQuery.Refresh would do the job. But not on your life..

The ONLY way I have been able to get this to work is do a Close/Open. ie
UniQuery.Close;
UniQuery.Open;

Now the UniQuery has the correct data and the fields on the form are updated.

The problem with this approach is we need to stay on the same record and doing an Open/Close does not always do that. It does in the above example, but I am usually loading in a lot of customer records and displaying them in a grid.
So I have tried doing this

Code: Select all

  B := query.GetBookmark;
                           try
                              query.close;
                              query.open;
                              try
                                 query.GotoBookmark(B);
                              except
                                 on e: exception do Log(e.Message);
                              end;
                           finally
                              query.FreeBookmark(B);
                          end
This does not work either. I have no idea why - as it looks a good idea.

This is all done on the same form, connecting through the same UniConnection to a Firebird 3 server.

Is there some secret to getting the UniQuery component to do a refresh? Can I tie into some event or something? I usually only want to refresh the current record - not the whole dataset. I might have popped up a form to do an edit on that one row in a grid, or I run a Exec query like I showed above, updating totals or something.

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: Refresh data from UniQuery

Post by oleg0k » Tue 12 May 2020 12:11

Hello,
To give you a detailed answer, we need to look into an example demonstrating the incorrect behavior.
Please send it to us, along with the scripts for creating and populating database objects, through the contact form on our website: https://devart.com/company/contactform.html

wbr, Oleg
Devart Team

kneighbour
Posts: 77
Joined: Wed 08 Oct 2008 04:55

Re: Refresh data from UniQuery

Post by kneighbour » Tue 12 May 2020 22:41

I thought I did exactly that? There are scripts above. The problem being that uniquery.refresh does not seem to do anything.

But this is not a new problem. I have used the Uni library for years and this has never worked. But I am hopeful that something can be done so will do up a small project showing this.

In doing up a test project I might have stumbled across the problem. Using standard Delphi components (ie TDBEdit, etc). It works. But not using third party. Am investigating.

Post Reply